Adding Pagination to Your DataGrid

The Paginator is a control that presents a list of page numbers, and a previous and next button, to let the user "scroll" the data a page at a time. It gives a limited view into a potentially very large data set.

In order to enable pagination, we need to define a Paginator object and assign it to the DataGrid. The DataGrid will render the paginator inside a caption tag in the table, and therefore, we will set the DataGridw as the Paginator's parent in the Paginator constructor call.

In the locally defined dtgPersons_Bind method, in addition to setting the datagrid's DataSource, we also give the datagrid the TotalItemCount (via a Person::countAll() call). And finally, when we make the Person::loadAll() call, we make sure to pass in the datagrid's LimitClause, which will pass the paging information into our loadAll() call to only retrieve the items on the page we are currently viewing.

Person ID
First Name
Last Name