SOBE ICT
2018-04-06T14:29:28Z
iGrid 6.0
C#
Win7

Hi Guys

I will save the last sorted columns including their sort order (Ascending / Descending). For that reason I added the event "AfterContentsSorted" to retrieve columns stored in the SortObject of the grid together with the sort order of the column.

This works until you have a mixed of ascending and descending sorted columns. The iGCol object's SortOrder property has always the "Ascending" order even if the column is sorted descending.

What I'm doing wrong?
Igor/10Tec
2018-04-07T09:38:10Z
Perhaps, a better name for the iGCol.SortOrder property would be "DefaultSortOrder". This column property stores the default sort order for the column (the order that will be used first when the user clicks the column's header to sort it). You can read about it in the electronic documentation.

If you need to know the effective sort order of a column, you need to use the column's SortIndex property. This property returns the zero-based index of the column within the SortObject (the current sort criteria) or -1 if it is not sorted. Having this, we could write the following code that displays the sort order of the column containing the current cell:

int sortIndex = iGrid1.Cols[iGrid1.CurCell.ColIndex].SortIndex;
if (sortIndex > -1)
  MessageBox.Show(iGrid1.SortObject[sortIndex].SortOrder.ToString());
else
  MessageBox.Show("Not sorted");

BTW, if you need to save/restore the current sort criteria, you can use the LayoutObject property of iGrid developed specially for this purpose.
SOBE ICT
2018-04-10T05:55:39Z
Hi Igor

Thanks for the information, will try it after my holiday
SOBE ICT
2018-04-17T14:06:46Z
Hi Igor

I checked the LayoutObject but it doesn't contain any information about the SORT order (only the column order):



<Col Index=\"2\">
<Order>2</Order>
<Visible>True</Visible>
<Width>166</Width>
</Col>
<Col Index=\"3\">
<Order>3</Order>
<Visible>True</Visible>
<Width>124</Width>
</Col>

Any other tips?
Igor/10Tec
2018-04-18T12:25:24Z
The LayoutObject.Text property returns the column parameters specified in the LayoutObject.Flags property. By default, only column visibility, width and order are returned. To include information about sorting, add the iGLayoutFlags.Sorting flag to the combination of flags in the LayoutObject.Flags property.
SOBE ICT
2018-04-24T11:17:24Z
Originally Posted by: Igor/10Tec 

The LayoutObject.Text property returns the column parameters specified in the LayoutObject.Flags property. By default, only column visibility, width and order are returned. To include information about sorting, add the iGLayoutFlags.Sorting flag to the combination of flags in the LayoutObject.Flags property.



Thanks, Igor. Works like a charm. Best regards