7. Paginated Controls
* QDataGrid Pagination
<< * QDataGrid Sorting   |   Back to Main   |   * Enabling AJAX on the QDataGrid >>

View Source
will open in a new window
Adding Pagination to Your QDataGrid
Now, we will add pagination to our datagrid.

In order to enable pagination, we need to define a QPaginator object and assign it to the QDataGrid. Because the QPaginator will be rendered by the QDataGrid (instead of being rendered on the form via a $this->objPaginator->Render() call), we will set the QDataGrid as the QPaginator's parent in the QPaginator 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.
Previous|1|Next Results: Viewing items 1-19 of 19.
Person ID First Name Last Name Sorted
16 asd asd
9 Linda Brady
19 df df
1 Teo Dirac
4 Mike Ho
2 Kendalll Jenner
6 Wendy jose
18 kalle kula
12 Jacob Pratt
8 Samantha prueba
3 Ben Robinson
17 sdfsdf sdfsdfsdf
5 Alejnadro Smith
10 Jennifer Smith
11 Brett Smiths
13 wdt t
14 w w
7 Karen Wolfe
15 w wwwgggggggg