Instead of retrieving a single row of data from my store, how can I modify the following code to retrieve all records?
var store = Ext.data.StoreManager.lookup('MyStore');
store.setProxy({
type: 'pagingmemory',
data: store.getAt(0)
});
store.load();
Any thoughts?
Instead of retrieving a single row of data from my store, how can I modify the following code to retrieve all records?
var store = Ext.data.StoreManager.lookup('MyStore');
store.setProxy({
type: 'pagingmemory',
data: store.getAt(0)
});
store.load();
Any thoughts?
Share Improve this question edited Dec 25, 2015 at 12:41 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Aug 20, 2013 at 16:13 Clay BanksClay Banks 4,58115 gold badges77 silver badges150 bronze badges 2 |4 Answers
Reset to default 9You can use store.getRange()
or you can use store.data.items
. For the getRange()
call, passing no parameters just defaults to 0 and the last record in the store.
I think this is not complete true, since getRange()
will retrieve all the records from a store first page.
If your store has pages of 50 records per page, then store.getRange()
will give you only the first 50 records.
This will reload the store with all records:
store.load({start:0, limit: store.totalCount, page:1});
Take all records from store:
var records = store.getRange();`
store.getRange()
will only retrieve the page currently worked on if the grid is not defined to have a buffered store. Store can be set as buffered by:
(buffered: true)
But that will decrease the performance since the whole page will be buffered even if a single page will be retrieved.
The most efficient way that comes to my mind is:
var pageSize = store.pageSize // will return the page size.
var totalCount = store.totalCount // This will return total no of items
for (var i=0; i<(totalCount/pageSize)+1;i++) {
store.loadPage(i) // this will set the current page of the store to i variable.
....
....
}
store.getRange()
should work or you can dostore.data.items
. For thegetRange()
call, passing no parameters just defaults to 0 and the last record in the store. – Jeff Shaver Commented Aug 20, 2013 at 16:19