The DataGrid Class and Sorting by Columns

Table, is great for drawing basic HTML tables, but can overload a web page when trying to display a large amount of information.

The DataGrid class is a subclass of Table and has features that allow the table to be a view into a larger set of data that is stored in a database, without rendering all the data. The effect gives the user fast access to large amounts of data.

One feature of DataGrid is it allows you to click on column headers to sort the data in the table. Sorting is provided by SQL, and each click causes the database to be queried with a sort clause corresponding to the column that was clicked.

To enable this, you add the properties OrderByClause and ReverseOrderByClause to each column. (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 DataGrid when you query the database in the data binder. You then pass this clause to your class's loadAll() or loadArrayBy...() method as one of the optional QQ Clause parameters. Note that all QCubed code generated loadAll() and loadArrayBy...() methods take in an optional $objOptionalClauses parameter which conveniently uses the clause returned by the DataGrid's OrderByClause method.

Convenient how they end up working together, isn't it? =)

Click on the column headers in the table to see the sorting in action.

Person Id
First Name
Last Name
4958
5058
5158
525741787887
56sdbvasdgvb
57sdbvasdgvb
53JosephBiden
54JosephBiden
55JosephBiden
9LindaBrady
11BrettCarlisle
1JohnDoe
4MikeHo
8SamanthaJones
12JacobPratt
2KendallPublic
3BenRobinson
5AlexSmith
10JenniferSmith
6WendySmith
7KarenWolfe