almakki
almakki

Reputation: 197

Load store filter to multiple lists

I have three lists in a view.I need to filter store on some basis to these lists.When i tried to load store same data appear for all three lists.

This is the code i tried.

var SStore = Ext.getStore('mystore');

SStore.clearFilter(true);


SStore.filter('status', '1');

Ext.getCmp('list1').setStore(SStore);

var BStore = Ext.getStore('mystore');

BStore.clearFilter(true);

BStore.filter('sattus', '2');

Ext.getCmp('bluetbl').setStore(BStore);

var RStore = Ext.getStore('mystore');

RStore.clearFilter(true);

RStore.filter('status', '3');

Ext.getCmp('redtbl').setStore(RStore);

Please help me to find out the solution.

Upvotes: 0

Views: 850

Answers (1)

alex
alex

Reputation: 166

every time you call Ext.getStore('mystore'); you get the same instance of the store, not a copy. this means that all your tables will share the same store with the last filter you applied. you should use a different store for each grid. something like

var SStore = Ext.getStore('mystore');

SStore.clearFilter(true);

SStore.filter('status', '1');

// ATTENTION Ext.getCmp('list1').setStore(SStore); the setStore method doesn't exist!

// instead you have to create your grid with SStore as store

var grid = new Ext.grid.GridPanel({store: SStore, autoLoad: false});
//autoLoad: false gives you control of the load


SStore.load(); // now the first grid gets populated



var BStore = Ext.getStore('mySecondStore');

BStore.clearFilter(true);

BStore.filter('status', '2'); //check the spelling of status

//Ext.getCmp('bluetbl').setStore(BStore); no..

//create your bluetbl grid with BStore as store

var secondGrid = new Ext.grid.GridPanel({store: BStore, autoLoad: false});
//autoLoad: false gives you control of the load


BStore.load(); // now the second grid gets populated

Upvotes: 1

Related Questions