7
votes

I am working on a grid which uses filters, but it only filters the first page. When I click 'next' it forgets about my filters and loads the next set of records. How do I make it remember the filter even if I click 'next' to load the next set of records from paging?

Thanks, SS

2

2 Answers

6
votes

You need to set the filter parameters into the store's baseParams. Passing your filter parameters in the load call on the store will only use them for the first load call — subsequent calls made by the paging toolbar won't pass them.

store.setBaseParam('query', 'search-text'); // always send 'query'
store.load({ params: { start: 0, limit: 40 } });
// this will send:
// { query: 'search-text', start: 0, limit: 40 }

store.load({ params: { query: 'bob', start: 41, limit: 40 } });
// baseParams overridden by load params
// { query: 'bob', start: 41, limit: 40 }

store.load();  // only sends baseParams
// { query: 'search-text' } 

The ExtJS Ext.data.Store docs have the details.

-1
votes

Setting the baseParams, like in the answer above, is only for EXTJS 3.x or less. For EXTJS 4.xx, we must add in the store's proxy, an extraParam with your query: store.getProxy().extraParam= A JSON ENCODED QUERY like: store.getProxy().extraParam= Ext.JSON.encode({'sort':[{'id':'ASC'}]}) For a proper configuration, investigate the your request, in your navigator developer's tools or in your backend