PDA

View Full Version : howto loop through entire filtered selection on paged grid



bruce.au
19 Oct 2015, 9:43 PM
I have filtered records on a grid
total = this.getStore().getTotalCount();
gives me 600 records
The grid ha paged with a page size of 100 records
Trying to loop through the selected records only gives me the first page.

How to I loop through all 6 pages?
selected = [];
store.each(function(record,id){
rec = record.get('id')
selected.push(rec);
});
only gives me 100 records

joel.watson
20 Oct 2015, 7:00 AM
Hi--

Assuming that your paging grid is using a remote data source, the only way to get all the data would be to make a request for all the data. The paged grid is going to retrieve the number of records that are configured for pageSize (e.g., 25, 50, 100, etc) for each "page" requested. Because of this, only this subset ("page") of data will be available in the store at any one time, as the "total count" is based on the totalProperty (http://docs.sencha.com/extjs/4.2.4/#!/api/Ext.data.reader.Reader-cfg-totalProperty) passed back in the response.

Thanks
Joel

bruce.au
22 Oct 2015, 11:38 AM
Instead of store.each(function(record,id) If I was able to get the filter data I could pass that to the server endpoint and run sql on the model to retrieve the records. How do I achieve that? getFilterData()

joel.watson
22 Oct 2015, 11:58 AM
If you have remoteFilter: true set on your store, the filter should be passed with the request in the querystring.

Thanks!
Joel

bruce.au
22 Oct 2015, 2:05 PM
Thanks Joel,

I have finally got it
var myfilters = this.filters;
var allfilters = myfilters.getFilterData();

gives me the result I was after