Book Image

Learning Ext JS_Fourth Edition

Book Image

Learning Ext JS_Fourth Edition

Overview of this book

Table of Contents (22 chapters)
Learning Ext JS Fourth Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Grid paging


The Grid panel supports paging through a large set of data with the help of a PagingToolbar item. To accomplish this we have to make some modifications to our store and add a PagingToolbar item to our grid. For this, we need to create our store, as shown in the following code:

Ext.define('Myapp.store.customers.CustomersC',{
  extend:'Ext.data.Store',
  model: 'Myapp.model.Customer',
  pageSize: 3,
  autoLoad:true,
  proxy:{
    type:'ajax',
    url: 'serverside/customersc.php',
    reader: {
      type:'json',
      rootProperty:'records',
      totalProperty:'total'
    },
    actionMethods :{read:'POST'}
  }
});

In the definition of our store, we declared a pageSize property of 3 and defined a proxy so that we can get the data from the server. Thus, we will be able to paginate our data.

Then we define our grid and the PagingToolbar item that this grid will have:

var myStore = Ext.create("Myapp.store.customers.CustomersC");
var myGrid = Ext.create('Ext.grid.Panel',{
  height: 250...