如下代码,如何为该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 如何在scanpy上做差异基因和通路富集?
- ¥20 关于#硬件工程#的问题,请各位专家解答!
- ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
- ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
- ¥30 截图中的mathematics程序转换成matlab
- ¥15 动力学代码报错,维度不匹配
- ¥15 Power query添加列问题
- ¥50 Kubernetes&Fission&Eleasticsearch
- ¥15 報錯:Person is not mapped,如何解決?
- ¥15 c++头文件不能识别CDialog