Sorting Data in Developer Express QuantumGrid
The data displayed by the QuantumGrid control can be sorted by one or several columns. Typically, users specify the sorting column and change the direction (ascending or descending) by clicking the column caption. However, creating script code that will simulate mouse clicks over column captions is not an easy task. The problem is that you will have to calculate the coordinates of the click and this is not easy, especially if the column belongs to a child level.
To simulate the sorting, you can use the internal methods and properties of the TcxGrid object (TcxGrid is the class name of the QuantumGrid control). This approach is a lot easier and stable than simulating the mouse click.
To sort the grid data by a column, the test script should perform the following actions:
- Get the column object that corresponds to the desired column.
- Use the
SortOrder property of the column object to specify the desired sorting order:
- 1 - Ascending
- 2 - Descending
- 0 - No sorting
Note that assigning 1 or 2 to the
SortOrder property of a column does not automatically cancel sorting by other column(s).
To perform these actions, TestComplete should have access to internal methods and properties of the TcxGrid object. That is, the tested application must be compiled as an Open Application with debug information.
The following sample demonstrates how to use internal methods and properties to sort grid data. The sample contains the following routines:
Here is the sample code: