【问题标题】:Disable item from combobox even from events listener / ExtJS甚至从事件侦听器/ ExtJS 禁用组合框中的项目
【发布时间】:2014-03-04 17:17:30
【问题描述】:

假设我有这家商店:

var statsType = Ext.create('Ext.data.Store', {
fields: ['id', 'grayedOutComboItem', 'type', 'typeClass'],
data: [{
    'id': '',
    'grayedOutComboItem': 'x-combo-grayed-out-item',
    'type': '== Moyennes ==',
    'typeClass': 'mean'
}, {
    'id': '1',
    'grayedOutComboItem': '',
    'type': 'Moyennes journalières',
    'typeClass': 'mean',
}, [...]

还有一个带有这个监听器的组合框:

        [...]
        listeners:
        {
            'beforeselect': function(combo, record, index)
            {
                return ("" != record.data.id);
            }, [...]

它之所以有效,是因为如果单击具有空 id 的项目,组合框显示中不会发生任何事情。
但问题在于,它仍然会触发侦听器的事件。
所以当你点击它时仍然可以触发东西。

如何禁用它,使其不再触发任何东西!

:)

【问题讨论】:

    标签: javascript extjs combobox


    【解决方案1】:

    要取消事件使其不触发,请使用:

    'beforeselect': function(combo, record, index, e) {
       if( "" == record.data.id ) {
          e.stopEvent();
       }
    }
    

    【讨论】:

    • 它仍然会触发事件,例如如果组合是 multiSelect: true,如果您选择一个活动项目然后单击禁用的项目,它会删除第一个的值。
    猜你喜欢
    • 2012-10-10
    • 2013-05-09
    • 1970-01-01
    • 2015-11-01
    • 2016-06-08
    • 1970-01-01
    • 1970-01-01
    • 2017-12-10
    • 1970-01-01
    相关资源
    最近更新 更多