最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Simply retrieving all records from a store - Stack Overflow

programmeradmin0浏览0评论

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
  • store.getRange() should work or you can do store.data.items. For the getRange() call, passing no parameters just defaults to 0 and the last record in the store. – Jeff Shaver Commented Aug 20, 2013 at 16:19
  • Throw it in an answer so I can give a an upvote! – Clay Banks Commented Aug 20, 2013 at 16:22
Add a comment  | 

4 Answers 4

Reset to default 9

You 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.  
         ....
         ....
    }
发布评论

评论列表(0)

  1. 暂无评论