本文介绍了ExtJS菜单checkItem:如何防止项目检查事件在某些情况下?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于菜单checkItem,当用户点击它时,默认情况下会触发checkchange;我想知道如果一个特定的情况下,不改变其检查状态,点击后,换句话说,停止这个事件链。
for a menu checkItem, when user clicks at it, by default it will trigger checkchange; i am wondering how to, if a certain case is met, not change its check status after clicked, in other words, stop this event chain.
我尝试了以下代码,但无法正常工作:
I tried following codes, but not work:
listeners: {
'click': function(item, evt) {
if(1) { //verify whether that certain case
evt.stopEvent(); //since click_event is triggered before setChecked()/checkChange, I thought this may stop its going further...
alert('case met!');
}
},
checkHandler: function(item, checked) {
//...
}
推荐答案
您可以监听 beforecheckchange
事件。
根据文档,只需应用条件逻辑,如果不通过,则从处理程序返回false。
As per the docs, just apply your conditional logic and if it doesn't pass, return false from the handler.
例如:
listeners: {
'beforecheckchange': function(item, checked) {
if(!1) { // or whatever your conditional logic is
return false;
}
},
}
这篇关于ExtJS菜单checkItem:如何防止项目检查事件在某些情况下?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!