0

アイテムがデータベースから来ているコンボボックスがあり、そのコンボボックスを使用してフィルターオプションを適用しています...コンボは最初はうまく機能しますが、2回目にコンボボックスからアイテムを選択したいときに問題がありますコンボ内のアイテムを検索します (以前に選択したアイテムのみ)。

this.control({
                    'combobox[itemId=YourCombo]':
                    {
                    select: this.combogridfilter
                    }
                    });       

combogridfilter: function(newValue){
    var value1= Ext.getCmp('myCombo').getValue();
        var grid=Ext.getCmp('afteraddingtemplate');
            grid.store.load().filter([
                {id:'item_code', property:"item_code", value: value1, anyMatch: false}
            ]);

    },

コンボ構成はこちら

xtype:'combo',
            id:'myCombo',
            itemId:'YourCombo',
            action:'change',
            fieldLabel:'Select a template',
            queryMode:'local',
            store:this.store,
            name:'item_code',
            displayField:'item_code',
            valueField:'item_code',
            enableKeyEvents: true,
            typeAhead: true,
            mode: 'local',
            forceSelection: true,
            triggerAction: 'all',
            emptyText: 'Select a Template',
            selectOnFocus: true 
4

2 に答える 2

1

新しいフィルターを適用する前に、フィルターをクリアする必要があります。

combogridfilter: function(newValue){
var value1= Ext.getCmp('myCombo').getValue();
    var grid=Ext.getCmp('afteraddingtemplate');
        grid.store.clearFilter(true);
        grid.store.filter('item_code', value1);
},
于 2013-06-24T09:03:42.093 に答える
1

グリッドとコンボの間でストアを共有しないでください。コンポーネント間でストアを共有すると問題が発生します。何が起こっているかというと、グリッドをフィルタリングすると、コンボもフィルタリングされます。同じ店だから…

できることは、コンボに単純なメモリ ストアを使用することです。これは、グリッド ストアがロードされたときに設定されます。

たとえば、コンボを次のように構成します。

{
    renderTo: Ext.getBody(),
    xtype:'combo',
    id:'myCombo',
    itemId:'YourCombo',
    action:'change',
    fieldLabel:'Select a template',
    queryMode:'local',
    store: {
        fields: ['item_code']
        ,proxy: {type: 'memory', reader: 'array'}
    },
    name:'item_code',
    displayField:'item_code',
    valueField:'item_code',
    enableKeyEvents: true,
    typeAhead: true,
    mode: 'local',
    forceSelection: true,
    triggerAction: 'all',
    emptyText: 'Select a Template',
    selectOnFocus: true 
}

そしてload、グリッド ストアのイベントでそれを設定します。

grid.getStore().on('load', function(store) {
    Ext.getCmp('myCombo').getStore().loadData(store.getRange());
});
于 2013-06-24T09:16:05.943 に答える