怎么为extjs的combobox添加监听器?

怎么为extjs的combobox添加监听器?,第1张

extjs 事件监听 都是在 创建这个 组件时,组件属性里 写上

listeners: {

select: function(){ 这里写触发后的动作 },

...

change: function(){ 这里写触发后的动作}

}

其中这些function 都有一些回调参数的,你在写的时候,可以参考api文档,了解每个参数的意义,使用起来会更加方便和完善;

另外 给组件添加事件监听,也可以动态的添加,比如:

combobox.on('select',function(){ 这个function 和上面所讲的function 是同样的 })

extjs所有的组件都是用 .on('监听器名称',function(){回调函数} ) 来动态添加...

ext其内部源码有这么一句话 this.el.dom.disabled = true

disabled 的属性 当submit提交时 不会提交后台

disabled 在IE8以上中有个bug,一般人很少遇到过:

<select id="select"><option>asdaasd</option></select>

document.getElementById("select").disabled = "disabled"

document.getElementById("select").disabled = true

如果disabled 被设置了disabled之后,你再设置为true的时候是无效的,必须设置为disabled = “”才会有效果

你可以试下citytemp.setDisabled("disabled")

实在不行就直接用dom元素去改,直接找到 document.getElementById("select").disabled = "disabled"就可以了

事件监听方法:

(1) 这个方法主要给dom对象来监听事件

Ext.get(document).on('事件',function(){ 处理方法})

(2)写在容器里面 如panel

listeners{'事件',function(){处理方法}}

(3)对定义的js类进行事件监听

var eastpanel=new Ext.Panel({

region:'east',

collapsible: true,

width: 275,

items: [{....}]

})

eastPanel.on("collapse",function(e){

alert("ssad")

})

举例:

如何给表单的textfield添加键盘监听事件:

var searchKey = new Ext.form.TextField({ //text

id: 'searchkey',

fieldLabel: 'text',

name: 'text',

defaultType: 'textfield',

grow: false,

blankText: "这个字段最好不要为空",

enableKeyEvents: true

})

searchKey.on('keypress', function(e){

// 监听回车按键

if (e.getKey() == e.ENTER &&this.getValue().length >0) {

alert("OK")}

})


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11617417.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-17
下一篇 2023-05-17

发表评论

登录后才能评论

评论列表(0条)

保存