Hello ethraza,
You need to set store pageSize and while fetching response from server you can return total records and no of records you want.
Below is the code which do exactly same stuff but different way.
Code:
Ext.define('MyApp.store.UserGridStore', {
extend: 'Ext.data.JsonStore',
storeId: 'UserGridStore',
sorters: 'name',
fields: [{
name: 'id',
mapping: 'id'
}, {
name: 'name',
mapping: 'name',
type: 'string'
}, {
name: 'firstName',
mapping: 'firstName',
type: 'string'
}, {
name: 'surName',
mapping: 'surName',
type: 'string'
}, {
name: 'email',
mapping: 'email',
type: 'string'
}, {
name: 'lastLoginDate',
mapping: 'lastLoginDate',
dateFormat: 'c',
type: 'date'
}, {
name: 'enabled',
mapping: 'enabled',
type: 'boolean'
}],
constructor: function(config) {
config = Ext.apply({
proxy: {
type: 'memory',
reader: {
type: 'json',
rootProperty: 'items',
totalProperty: 'total'
},
writer: 'json'
}
}, config);
this.callParent([config]);
}
});
Server will give below response with page all grid data in items element and total will have total records in whole table.
Code:
{
'items': [{
'id': 1,
'name': 'admin',
'surName': '',
'firstName': '',
'email': '[email protected]',
'lastLoginDate': '2016-01-20 20:08:05'
'enabled': true
}, {
'id': 2,
'name': 'test',
'surName': '',
'firstName': '',
'email': '[email protected]',
'lastLoginDate': ''
'enabled': true
}],
'total': 5
}
On toolbar beforechange event you can fetch data again and set the store and refresh grid.
Code:
Ext.getCmp('tbPaging').on('beforechange', function(tb, page) {
// Your fetch record code goes here with page.
});
in above code page will give you current page. So if you click next then it will give you next page number.
So using single request you can have pagesize and result and grid will use that from store.
Thanks,
Dhaval