Skip to main content
Tab

ASPxVerticalGrid.CustomRowSort Event

Enables you to sort data using custom rules.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.2.dll

Declaration

public event ASPxVerticalGridCustomRowSortEventHandler CustomRowSort

Event Data

The CustomRowSort event's data class is ASPxVerticalGridCustomRowSortEventArgs. The following properties provide information specific to this event:

Property Description
Handled Gets or sets whether a comparison operation is handled, and therefore, no default processing is required. Inherited from GridCustomColumnSortEventArgs.
ListSourceRowIndex1 Gets the index in the data source of the first of the two data items (row, card or record) being compared. Inherited from GridCustomColumnSortEventArgs.
ListSourceRowIndex2 Gets the index in the data source of the second of the two data items (row, card or record) being compared. Inherited from GridCustomColumnSortEventArgs.
Result Gets or sets the result of a custom comparison. Inherited from GridCustomColumnSortEventArgs.
Row Gets the row whose values are being compared.
SortOrder Gets the sort order applied to the column (row for ASPxVerticalGrid) being processed. Inherited from GridCustomColumnSortEventArgs.
Value1 Gets the first value being compared. Inherited from GridCustomColumnSortEventArgs.
Value2 Gets the second value being compared. Inherited from GridCustomColumnSortEventArgs.

The event data class exposes the following methods:

Method Description
GetRow1Value(String) Returns the specified column’s value in the first data item (row, card or record) being compared. Inherited from GridCustomColumnSortEventArgs.
GetRow2Value(String) Returns the specified column’s value in the second data item (row, card or record) being compared. Inherited from GridCustomColumnSortEventArgs.

Remarks

A row’s Settings.SortMode (GridDataColumnSettings.SortMode) property specifies how the grid’s data is sorted when sorting is applied to this row. If this property is set to ‘Custom’, a custom sorting algorithm can be implemented for this column by handling the CustomRowSort event.

When the CustomRowSort event is fired, two records should be compared. The row being processed is specified by the ASPxVerticalGridCustomRowSortEventArgs.Row parameter. The GridCustomColumnSortEventArgs.Value1 and GridCustomColumnSortEventArgs.Value2 parameters identify the record values within this row.

The result of the custom comparison should be set to the GridCustomColumnSortEventArgs.Result parameter as shown below:

  • set Result to -1 if the first record should be positioned above the second record when data is sorted in ascending order. When data is sorted in descending order, the first record will be positioned below the second record.
  • set Result to 1 if the first record should be positioned below the second record when data is sorted in ascending order. When data is sorted in descending order, the first record will be positioned above the second record.
  • set Result to 0 to indicate that the records are equal. In this case, the records will be arranged within the grid according to their indexes in the data source.

The GridCustomColumnSortEventArgs.Handled parameter should be set to true if the current comparison operation was handled. You can leave this parameter set to false to invoke the default comparison mechanism after your event handler has finished. In this case, the custom comparison operation’s result is ignored.

See Also