Skip to main content

ASPxClientGridView.SortBy(column) Method

Sorts data by the values of the specified data column.

Declaration

SortBy(
    column: ASPxClientGridViewColumn | number | string,
    sortOrder?: string,
    reset?: boolean,
    sortIndex?: number
): void

Parameters

Name Type Description
column string | number | ASPxClientGridViewColumn

The data column | The column’s index | The column’s fieldName

sortOrder string

The column’s sort order. Available values:
"ASC" or undefined to sort data in ascending order.
"DSC" to sort data in descending order.
"NONE" to clear sorting by column values.

reset boolean

true or undefined to clear the previous sorting.
false to keep the previous sorting.

sortIndex number

The column’s sort priority.

Remarks

Call the SortBy(column) method to sort data in the grid by column values. You can also specify the following parameters in the SortBy(column) method:

  • The column’s sort order.
  • The value that identifies whether to clear the previous sorting.
  • The column’s sort priority.

For more information on sorting in the grid, refer to the following topic: ASPxGridView - Sort Data.

<dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" AutoGenerateColumns="False"
    KeyFieldName="ProductID">
    <Columns>
        <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="0" SortIndex="0" />
        <dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="1" SortIndex="1" />
        <dx:GridViewDataTextColumn FieldName="UnitsInStock" VisibleIndex="2" SortIndex="2"/>
        <dx:GridViewDataCheckColumn FieldName="Discontinued" VisibleIndex="3" />
        <dx:GridViewDataTextColumn FieldName="UnitsOnOrder" VisibleIndex="4" />
    </Columns>
</dx:ASPxGridView>
<br />
<dx:ASPxButton ID="button" runat="server" Text="Custom action" AutoPostBack="false">
    <ClientSideEvents Click="OnClick" />
</dx:ASPxButton>
function OnClick(s, e) {
    grid.SortBy("Discontinued", "DSC", false, 1);
}
See Also