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
9 Linda Brady
11 Brett Carlisle
1 Pop Doe
4 Mike Ho
8 Samantha Jones
12 Jacob Pratt
2 Kendall Public
3 Ben Robinson
6 Wendy Smith
5 Alex Smith
10 Jennifer Smith
7 Karen Wolfe