1

我正在使用listner beforequery 来过滤组合框。过滤时一切都很好,但我面临一个问题,例如:

当我们在组合框中输入所需的字符以过滤它们时,它们会被自动选择..所以当我们想要输入新字符时,我们必须按右侧箭头来删除选择,否则剩余的字符将被删除......请帮助解释为什么这种行为。

代码:

xtype: 'combo',
            fieldLabel: 'Label',
            anchor: '100%',
            enableKeyEvents: true,
            allowBlank: false,
            displayField: 'value',
            store: 'level1Store',
            lazyInit: false,
            mode: 'local',
            forceSelection: true,
            disableKeyFilter: true,
            editable: true,
            triggerAction: 'all',
            valueField: 'key',
            name: 1,
            ref: 'combo1',
            id: 'field1'

要过滤的侦听器代码:

Ext.getCmp('field1').addListener({
        beforequery: function (e) {
            if (e.query && e.query.indexOf('?') != -1) {
                e.cancel = true;
                var query = new RegExp(String.format('^{0}', e.query.replace(/\?/g, '[A-Za-z0-9]')));
                this.onLoad();
                this.store.clearFilter(true);
                this.store.filter(this.displayField, query);
            }
        }
    });
4

1 回答 1

1

你可以做两件事:

1)您可以用您自定义的所需行为覆盖此默认行为。

2)您可以收听组合的焦点事件并取消选择文本。

于 2012-05-05T15:29:30.080 回答