ExtJS menu checkItem: how to prevent item check ev

2019-07-17 01:13发布

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条回答
爷的心禁止访问
2楼-- · 2019-07-17 02:06

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;
        }
    },
}
查看更多
登录 后发表回答