Back to Devexpress

GridViewDataColumn.UnSort() Method

aspnet-devexpress-dot-web-dot-gridviewdatacolumn-381bfeda.md

latest2.7 KB
Original Source

GridViewDataColumn.UnSort() Method

Clears the sorting applied to the column.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public void UnSort()
vb
Public Sub UnSort

Remarks

When you call the UnSort method, the grid behaves as follows:

  • Clears the sorting by the specified column.

  • Sets the SortIndex property to -1.

  • Sets the SortOrder property to None.

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

aspx
<dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" AutoGenerateColumns="False"
    KeyFieldName="ProductID" OnCustomCallback="grid_CustomCallback">
    <Columns>
        <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="0" SortIndex="0" SortOrder="Ascending" />
        <dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="1" SortIndex="1" SortOrder="Descending" />
        <dx:GridViewDataTextColumn FieldName="UnitsInStock" VisibleIndex="2" SortIndex="2" SortOrder="Ascending" />
        <dx:GridViewDataCheckColumn FieldName="Discontinued" VisibleIndex="3" />
        <dx:GridViewDataTextColumn FieldName="UnitsOnOrder" VisibleIndex="4" />
    </Columns>
</dx:ASPxGridView>


<dx:ASPxButton ID="button" runat="server" Text="Custom action" AutoPostBack="false">
    <ClientSideEvents Click="OnClick" />
</dx:ASPxButton>
js
function OnClick(s, e) {
    grid.PerformCallback();
}
csharp
protected void grid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) {
    var column = (GridViewDataColumn)grid.Columns["ProductName"];
    column.UnSort();
}
vb
Protected Sub grid_CustomCallback(ByVal sender As Object, ByVal e As ASPxGridViewCustomCallbackEventArgs)
    Dim column = CType(grid.Columns("ProductName"), GridViewDataColumn)
    column.UnSort()
End Sub

See Also

GridViewDataColumn Class

GridViewDataColumn Members

DevExpress.Web Namespace