The Grid – Basics of Paging

by Shea Frederick on April 1st, 2007

I would suggest downloading the code used for this example here so you have something to work with. A working example can be found here.

Grid Data

A paging grid must have a server side element to perform the breaking up of data into pages.

For this example we are using php as the server side language, and a MySQL database with some randomly generated data. The PHP script below is used to retrieve our data and break it up into pages using the limit and start variables that are passed from the paging toolbar.

Were not going to dig much into the server side code, since it can vary quite a bit for each developers needs and environment.

Whats Needed to Make a Paged Grid?

NOTE: The example uses ScriptTagProxy only because the data resides on a different server from the example code. In most cases you will be pulling data from the same server the code resides on and using HttpProxy.

The only difference in the data Store is the addition of a totalProperty declaration. In our example, we use 'total' which is coming from our server side script with the value for the total number of rows we had before breaking them up into pages.

The Paging Bar

Adding a paging toolbar to the bottom of the grid pane, and your almost done.

The last step is to pass the initial start and limit parameters to your data load.

A large portion of the time spent setting up paging is going to be your server side environment that handles passing data back and forth with the grid, once you have that in place the task of adding paging to a grid can be very simple.

The Final Product

grid-paging.js

grid-paging-working.php

2 Comments
  1. Jangla permalink

    How can this example work? I thought ScriptTagProxy needed a callback function which would be immediately executed on returning from the server?

    • Notice the last line of my PHP file – where the data is returned – it wraps the return in a function, who’s name is provided in the request.

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS