如下代码,如何为该checkbox添加一个单击事件?越详细越好,谢谢!
......
......
var checkboxModule = new Ext.form.Checkbox({
id : "reportId",
name : "reportIDs",
autoScroll : false,
width : 90,
boxLabel : reportName,
inputValue : reportId,
anchor : "90%",
hideLabel : true,
//为checkbox添加选中事件
});
Ext.form.Checkbox 单击选中事件
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
4条回答 默认 最新
- suziwen 2010-03-18 10:01关注
我昨晚试了一下修改CHECKBOX的CLICK事件,发现不是那吗好改的,
没事把代码贴出来让大伙研究研究,
也感觉出什么EXT不提供CLICK事件了
[code="js"]
Ext.getBody().update();var checkboxextend = Ext.extend(Ext.form.Checkbox, { initComponent : function(){ Ext.form.Checkbox.superclass.initComponent.call(this); this.addEvents( 'click')}, afterRender : function(){ Ext.form.Checkbox.superclass.afterRender.call(this); this.on( 'click', this.onClick, this); }, onClick : function(){ this.fireEvent("click", this); } } ); var dule = new checkboxextend({ checked : true,
id : "reportId",
name : "reportIDs",
listeners : { "click" : function(obj,ischecked){alert('sdfsdfsd');}}
});
//dule.on('click',function(){alert('gamessss');});
var fp = new Ext.FormPanel({
frame: true,
title:'Check/Radio Groups',
labelWidth: 110,
width: 600,
renderTo:Ext.getBody(),
items : [dule],
bodyStyle: 'padding:0 10px 0;'});[/code]
这个代码会当用户点击时发生死循环,一直ALERT,只能杀进程,所以说,use own your risk!!!!
不过对于你的情况可以这样处理
当你要动态附值时,先取消check事件
[code="js"]un( String eventName, Function handler, [Object scope] ) : void
Removes a listener (shorthand for removeListener)
Parameters:
eventName : String
The type of event to listen for
handler : Function
The handler to remove
scope : Object
(optional) The scope (this object) for the handler
Returns:
void[/code]
附完值后再
on 这 个check事件
[code="java"]on( String eventName, Function handler, [Object scope], [Object options] ) : void
Appends an event handler to this element (shorthand for addListener)
Parameters:
eventName : String
The type of event to listen for
handler : Function
The method the event invokes
scope : Object
(optional) The scope in which to execute the handler function. The handler function's "this" context.
options : Object
(optional)
Returns:
void[/code]本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 vhdl+MODELSIM
- ¥20 simulink中怎么使用solve函数?
- ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
- ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
- ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
- ¥15 知识蒸馏实战博客问题
- ¥15 用PLC设计纸袋糊底机送料系统
- ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
- ¥15 用C语言输入方程怎么
- ¥15 网站显示不安全连接问题