7. Paginated Controls
* QDataGrid Sorting
<< * The QDataGrid Variables   |   Back to Main   |   * QDataGrid Pagination >>

View Source
will open in a new window
Sorting a QDataGrid by Columns
In this example we show how to make the datagrid sortable by individual columns.

For each column, we add the properties OrderByClause and ReverseOrderByClause (it is possible to also just define OrderByClause, and to leave ReverseOrderByClause undefined). The QQ Clause you specify is given back to you when you call the OrderByClause property on the QDataGrid itself.

So what you do is you specify the QQ OrderBy Clause that you would want run for each column. Then you pass the this clause to your class's LoadAll or LoadArrayArrayByXXX method as one of the optional QQ Clause parameters. Note that all Qcodo code generated LoadAll and LoadArrayByXXX methods take in an optional $objOptionalClauses parameter which conveniently uses the clause returned by the QDataGrid's OrderByClause method.

Convenient how they end up working together, isn't it? =)
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