Search code examples
extjsextjs3

Extjs3.4 Get all data from grid store which more than 1 page


How to get all data from a grid which have more than 1 page?

I set only to display 50 records in a page, but my total data is up to 52 records which store into 2 pages.


enter image description here

May i know how to get all data from this 2 pages?

Below is the code which only can get 1 page data...

ExportButtonTestJS = Ext.extend(One.Report, {
    reportName: 'ExportButtonTestRpt',
    autoExecute: true,
    isDetailPage: false,
    listeners: {
        bbarconfig: function(report, bbarConfig) {
          bbarConfig.items.push({
            xtype: 'button',
            text: 'Export',
            disabled: false,
            onClick : function () {
                console.log(report.grid.getStore().data.items);
                }
          });
        }
    }
});

Solution

  • Default page size is 50 for Ext.data.store. So even the data in store is more than 50 records (like for example 400) only 50 records will be stored in a Ext.store at any time. Once we go to next page next records from 51 to 100 records will be stored in store.

    Two solutions for your requirement:

    1. Increase pageSize as you want -- Eg: pageSize:500
    2. Set buffered:true in Ext.data.store

    On setting buffered:true, you can get all records of store at a time by using grid.store.getRange(start, end). But in this case you need to load the store once for the first time.