1

我有一个带有远程存储的 ExtJS 组合框(4.1 版)。当组合框被清空时,需要清除组合框并存储。

为此,我实现了一个清除组合框并存储按键和更改事件的函数(参见下面的代码)。

但是,当用户选择全部(如果光标在末尾,则 shift+home 或如果光标在开头,则 shift+end)然后按退格/删除时,组合框拒绝清空自己。在这种情况下,组合框在失去焦点时始终使用最后选择的值填充自身。这仅在 IE(我的客户使用)中发生。

知道如何防止组合框这样做吗?

下面的代码片段:

// clearExistingInput function (called from combo box)
clearExistingInput: function(ths, newVal) {
    if(newVal === null){
        ths.store.removeAll();
        ths.clearValue();
    }
}

// combo box configuration
{
    labelAlign : 'right',
    xtype: 'combo',
    store: comboStore,
    filterOnLoad: true,
    typeAhead: true,
    hideTrigger:true,
    minChars :1,            
    size:15,
    queryDelay: 20, 
    queryCaching: false,
    // enable paging with width that fits the paging toolbar
    matchFieldWidth: false,
    listConfig: {
        width: 220,
        height: 300, 
        autoHeight: true
    },
    maxWidth: 35,
    pageSize: true,

    enableKeyEvents:true,
    listeners:{
        'keypress':function(ths,e){ 
            if (e.getKey() == e.DELETE || e.getKey() == e.BACKSPACE) {
                this.up('formFilter').clearExistingInput(ths, ths.value);
            }
         },
        'change': function(ths,newVal,OldVal,eOpts){
            this.up('formFilter').clearExistingInput(ths, newVal);
        }
    }
}

// combo box store
comboStore = Ext.create('Ext.data.Store', {
      pageSize: 10,
      autoLoad: false,
      proxy: {
            type: 'ajax',
            url : 'Service/data',
            reader: {
                type: 'json',
                root: 'data'
            }
        },
        fields: [
          {name: 'data', type : 'String'}
        ]
});
4

0 回答 0