Intersoft WebGrid Documentation
Sorting Data
See Also Send comments on this topic.
Intersoft WebGrid > WebGrid Features Overview > Sorting Data

Glossary Item Box

WebGrid provides sorting features to customize the data that has been loaded. This allows users to see their data in a more organized way. This topic provides an overview of the sorting feature in WebGrid.

 This topic contains the following sections:

Enable Sorting

To enable sorting in WebGrid, you only need to set property AllowSorting to Yes. Data can be sorted based on a column by clicking on the column header. The sort order of subsequent click is, Ascending, Descending and then back to None. Alternatively, you can also do the sort selectively by right clicking on the column header and select on either Sort Ascending or Sort Descending.

Predefined Sorting Column

To set which column that you want to have sorting, you need to define the SortedColumns property.

Example:

Code Copy Code
<RootTable>  <SortedColumns>
          <ISWebGrid:WebGridGroup ColumnMember="ContactName" SortOrder="Ascending" />
  </SortedColumns>
</RootTable>

For further information, please read How-to: Sort Column Initially.

Sorting Types

Normally, when the sorting is enabled, WebGrid performs sorting for a single column. However, you can also enable multiple sorting in WebGrid by setting additional property, HeaderClickAction to SortMulti.

Users can sort multiple columns by pressing SHIFT key when click on column header.

Sorting Value List

In some scenarios, you may want to sort other key field while the ColumnMember is a field which translated by ValueList such as CategoryID. One of the most implemented scenarios is where you used ValueList to translate the CategoryID into useful information such as CategoryName.

You might be more familiar to do sorting with CategoryName than CategoryID. To sort by using ValueList, you only need to set UseValueListForSorting property in WebGridColumn.

Code Copy Code
<ISWebGrid:WebGridColumn Caption="CategoryID" DataMember="CategoryID" DataType="System.Int32"
                        Name="CategoryID" Width="100px" UseValueListForSorting="Yes">
                        <ValueList DataMember="DefaultView" DataSourceID="AccessDataSource2" 
                            DataTextField="CategoryName" DataValueField="CategoryID">
                        </ValueList>
</ISWebGrid:WebGridColumn>

Support Child Rows Sorting in Self-referencing Mode

WebGrid introduces a new setting in SelfReferenceSettings object called ApplyChildSorting. This feature instructs WebGrid to perform sorting on the self-referencing child when the column sorting action occurred.

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.