开发者

ExtJS paging grid filters only the first page

I am working on a grid which uses filters, but it only filters the first page. When I click '开发者_JAVA技巧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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜