0

I have a comboBox in which items are coming from database and a have applied filter option using that comboBox...Combo works good at first time ,but the problem is when i want to select items from the comboBox at second time i don't find items in my combo(only the previous selected item)..

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}
            ]);

    },

here is the combo configuration

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 
Mir Gulam Sarwar
  • 2,588
  • 2
  • 25
  • 39

2 Answers2

1

You should clear filter before applicate a new one:

combogridfilter: function(newValue){
var value1= Ext.getCmp('myCombo').getValue();
    var grid=Ext.getCmp('afteraddingtemplate');
        grid.store.clearFilter(true);
        grid.store.filter('item_code', value1);
},
Aminesrine
  • 2,082
  • 6
  • 35
  • 64
1

You should not share the store between the grid and the combo. Sharing stores between components is asking for trouble. What is happening, is that when you filter the grid, you filter the combo too. Given it's the same store...

What you can do is use a simple memory store for your combo, that you populate when the grid store is loaded.

For example, configure your combo this way:

{
    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 
}

And populate it on the load event of the grid store:

grid.getStore().on('load', function(store) {
    Ext.getCmp('myCombo').getStore().loadData(store.getRange());
});
rixo
  • 23,815
  • 4
  • 63
  • 68