Search code examples
filterextjspaginationgrid

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 '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?


Solution

  • 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.