Edit this page

Sorting with DataProvider

When RadVirtualGrid populates its data through the DataProvider mechanism, the sorting operation will be handled out-of-the-box. By default, the sorting of the control is enabled. The user can sort the data through the UI by clicking the column headers. Each click on a given column header will go to the consequent sorting state from one of the following ones: Ascending, Descending and No Sort.

The sorting of RadVirtualGrid can be disabled by setting the IsSortable property to False.

Figure 1: Sorting RadVirtualGrid through the UI

Opening the FilteringControl of RadVirtualGrid

Sorting through ColumnSortDescriptor

The ColumnSortDescriptor of a given column can be fetched through the GetSortDescriptorForColumn method of RadVirtualGrid by providing the index of the needed column.

Example 1: Getting the ColumnSortDescriptor of a column

var sortDescriptor = this.VirtualGrid.GetSortDescriptorForColumn(0);

Through the ColumnSortDescriptor, the sorting state can be set by manipulating its SortDirection property.

Example 2: Setting the SortDirection property

var sortDescriptor = this.VirtualGrid.GetSortDescriptorForColumn(0);
sortDescriptor.SortDirection = System.ComponentModel.ListSortDirection.Ascending;

See Also