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
1351
2512
2612
404asdads
394asdads
384asdads
374asdads
364asdads
44asdasasdads
45asdasasdads
41asdasasdads
42asdasasdads
43asdasasdads
27asdfasdf
2151ññ
2251ññ
2351ññ
2451ññ
2051ññ
1951ññ
1851ññ
1751ññ
1651ññ
1551ññ
1451ññ
9LindaBrady
11BrettCarlisle
1JohnDoe
4MikeHo
8SamanthaJones
34lolk
33lolk
32lolk
28lolk
35lolk
29lolk
30lolk
31lolk
12JacobPratt
2KendallPublic afd
3BenRobinson
5Alex1Smith
10JenniferSmith
6WendySmith
7KarenWolfe