-
Sorting rows in GridEX Control [Janus GridEX WinForms Control v3.5 for .NET]
GridEX control allows you to sort rows in a table by an unlimited number of columns. Sorting can be done with any data source supported by the control even if the data source doesn't have intrinsic sorting functionality. You can define which columns the rows are sorted by in a GridEX control at design time, programmatically or by user interaction.
At design time, you can add the sort keys in any table using the "GridEX Designer". The steps to add sort keys at design time are as follows:
1) Right Click in a GridEX control and click at "Grid Designer…" menu . The GridEX designer will appear.
2) In the GridEX Designer, select the "SortKeys" node under the table to be sorted.
3) In the Right panel, Click in the "Add" button to add a new sort key and select the column to be sorted and the sort order for that key.
4) Repeat the add operation until you have finished adding sort keys and click OK in the designer.
Programmatically, create a GridEXSortKey object specifying the column to be sorted and its sort order and add the sort key to the SortKeys collection of the table. For instance:
Sorting by columns ‘FirstName' and ‘LastName' in the root table of a GridEX control.
Dim sortKey As GridEXSortKey
Dim column As GridEXColumn
'Removing any sort key that may be present in the table
GridEX1.RootTable.SortKeys.Clear()
'get the column to be sorted
column = GridEX1.RootTable.Columns("LastName")
'create the sort key
sortKey = New GridEXSortKey(column, SortOrder.Ascending)
'add the sort key to the SortKeys collection of the table
GridEX1.RootTable.SortKeys.Add(sortKey)
'to sort by more than one column, create as many sort keys
'as are needed and add them to the SortKeys collection.
'add another sort key
column = GridEX1.RootTable.Columns("FirstName")
sortKey = New GridEXSortKey(column, SortOrder.Ascending)
GridEX1.RootTable.SortKeys.Add(sortKey)
Users are capable to sort rows by one or more columns; to sort rows by a column, click at the header of the column to be sorted. A second click at a column already sorted will change its sort order. To sort by more than one column in a GridEX control, click at the columns to be sorted while the Shift key is pressed. To prevent users sorting by a column, you can set the AllowSort property as False for that column and to prevent sorting in all the columns of a GridEX control set the AutomaticSort property to False.
Note : By default, GridEX control sorts rows comparing the values of cells. To sort rows based on the displayed text in a cell, like when using columns that have a ValueList or a GridEXDropDown replacing the cell value with the text associated to that value, set the CompareTarget property of that column equal to ColumnCompareTarget.Text. For instance:
Source Of Information : Janus v3.5 Help Files for VS 2008
Dim column As GridEXColumn
column = GridEX1.RootTable.Columns("CategoryID")
column.HasValueList = True
'populating the value list in order to show the CategoryName
'instead of the CategoryID in a column.
column.ValueList.PopulateValueList(
_objDataSet.Categories.DefaultView, _
"CategoryID", "CategoryName")
'specifying that the control should sort this column using the
'category name and not the CategoryID that is its real value.
column.CompareTarget = ColumnCompareTarget.Text
Subscribe to:
Post Comments (Atom)
0 comments: