ASPxGridView.BeforeColumnSortingGrouping Event
Fires before a column is sorted or grouped.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
Declaration
public event ASPxGridViewBeforeColumnGroupingSortingEventHandler BeforeColumnSortingGrouping
Event Data
The BeforeColumnSortingGrouping event's data class is ASPxGridViewBeforeColumnGroupingSortingEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Column | Gets a column whose sort or group order has been changed. |
OldGroupIndex | Gets the column’s previous position among grouped columns. |
OldSortIndex | Gets a column’s (row’s for ASPxVerticalGrid) previous position among sorted columns (rows). Inherited from ASPxGridBeforeColumnGroupingSortingEventArgs. |
OldSortOrder | Gets a column’s (row’s for ASPxVerticalGrid) previous sort order. Inherited from ASPxGridBeforeColumnGroupingSortingEventArgs. |
Remarks
The BeforeColumnSortingGrouping
event allows you to perform custom actions before a column is sorted or grouped.
In the example below, the control raises the BeforeColumnSortingGrouping
event to change the column visibility.
<dx:ASPxGridView ID="grid" runat="server" AutoGenerateColumns="False"
KeyFieldName="ProductID" OnBeforeColumnSortingGrouping="grid_BeforeColumnSortingGrouping">
<Columns>
<dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="0">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Name="VisibleProductName" FieldName="ProductName" VisibleIndex="1">
<Settings AllowGroup="True" SortMode="Custom" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Name="InvisibleProductName" FieldName="ProductName" VisibleIndex="2"
Visible="False" />
<dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="2" />
</Columns>
<Settings ShowGroupPanel="True" />
</dx:ASPxGridView>
protected void grid_BeforeColumnSortingGrouping(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewBeforeColumnGroupingSortingEventArgs e) {
if(e.Column.Name == "VisibleProductName")
grid.Columns["InvisibleProductName"].Visible = ((grid.Columns["VisibleProductName"] as GridViewDataColumn).GroupIndex != -1);
}
See Also