ExtJS menu checkItem: how to prevent item check event in certain circumstance?

匆匆过客 提交于 2020-01-04 05:52:40

问题


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) {
   //...
}

回答1:


You can listen to the beforecheckchange event. Here it is in the docs.

As per the docs, just apply your conditional logic and if it doesn't pass, return false from the handler.

E.g.:

listeners: {
    'beforecheckchange': function(item, checked) {
        if(!1) { // or whatever your conditional logic is
            return false;
        }
    },
}


来源:https://stackoverflow.com/questions/11089323/extjs-menu-checkitem-how-to-prevent-item-check-event-in-certain-circumstance

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!