Grid Sort questions..

Hi All,

I have a non-data aware advwebgrid where columns are created in code. For each column, I set CanSort = true, SoftFormat according to datatype and ColumnHeaderClick = true, and for the grid as such I have AsyncSort = true, and SortSettings are Column = 0, Direction = sdAscending, initialdir = sdAscending and Show = true.

When my grid is filled, it's based on an SQL query, and the order in which the grid is filled is according to the SQL select.

1. When I click a column-heading it sorts the column in Descending order first, and in Ascending at the next click. What do I need to do to get I to sort it Ascending first and then Descending at second click ?

2. Is the settings in grid.Sortsettings intended to sort the filled Grid according to the settings, once the grid is filled (that is Ascending at column 0), regardless of in which order the grid was filled ?

3. and If the grid is not sorted initially according to SortSettings, then where and when will the settings in SortSettings apply ?
 
NB! I have studied the "TMS IntraWeb Grids" pdf file for all to do with Sort, but still seem not to find an answer. Can anyone help please ?

Regards
Soren
Hi,

You can use the QSort call to sort the grid based on the SortSettings.

Example:
  TIWAdvWebGrid1.QSort;
Hi Bart,

Thanks for your reply. I will give it a try and see how I can use it.

For the question in point 1, could you tell me how to set it up to perform the sort in Ascending order when I click the column header the first time ?

Regards
Soren

You can use the OnColumnHeaderClick to set the SortSettings.Column and then call QSort.
For an example, please have a look at the GridSort page of the TMS IW FeaturesDemo.