Skip to main content

ASPxClientGridView.ColumnSorting Event

Fires before the grid sorts its data by column values.

Declaration

ColumnSorting: ASPxClientEvent<ASPxClientGridViewColumnCancelEventHandler<ASPxClientGridView>>

Event Data

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

Property Description
cancel Specifies whether to cancel the related action (for example, row edit, export). Inherited from ASPxClientCancelEventArgs.
column Gets the processed client column.

Remarks

The grid allows users to sort its data by multiple columns. When a user clicks the grid’s header to sort data, the control raises the ColumnSorting event. You can use the cancel argument property to prevent users from sorting data by the processed column.

The following example prevents users from sorting grid data by ProductName:

<dx:ASPxGridView ID="grid" runat="server" ClientInstanceName="grid">
    <ClientSideEvents ColumnSorting="OnColumnSorting" />
    <Columns>
        <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="0" />
        <%--...--%>
    </Columns>
</dx:ASPxGridView>
function OnColumnSorting(s, e) {
    if(e.column.fieldName == "ProductName")
        e.cancel = true;
}

Handle the BeforeColumnSortingGrouping event to perform custom actions before the GridView control sorts associated data. Refer to the following topic for more information: ASPxGridView - Sort Data.

See Also