Back to Devexpress

ASPxGridView.GetGroupedColumns() Method

aspnet-devexpress-dot-web-dot-aspxgridview-55ed09a4.md

latest4.9 KB
Original Source

ASPxGridView.GetGroupedColumns() Method

Returns a collection of grouped columns.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public ReadOnlyCollection<GridViewDataColumn> GetGroupedColumns()
vb
Public Function GetGroupedColumns As ReadOnlyCollection(Of GridViewDataColumn)

Returns

TypeDescription
ReadOnlyCollection<GridViewDataColumn>

The collection of grouped columns.

|

Remarks

ASPxGridView supports data grouping by multiple columns. Call the GetGroupedColumns method to access the collection of grouped columns.

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

The code sample below uses the GetGroupedColumns method to traverse through the grouped columns and sort them in descending order.

aspx
<dx:ASPxGridView ID="grid" runat="server" OnCustomCallback="grid_CustomCallback">
    <%--...--%>
    <Settings ShowGroupPanel="true" />
</dx:ASPxGridView>
csharp
protected void grid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) {
    var collection = grid.GetGroupedColumns();
    foreach(var item in collection) {
        item.SortDescending();
    }
}
vb
Protected Sub grid_CustomCallback(ByVal sender As Object, ByVal e As ASPxGridViewCustomCallbackEventArgs)
    Dim collection = grid.GetGroupedColumns()

    For Each item In collection
        item.SortDescending()
    Next
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetGroupedColumns() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

asp-net-web-forms-grid-create-report-based-on-grid-layout/CS/WebApplication1/ReportHelper.cs#L57

csharp
if(aspxGridView1.GroupSummary.Count > 0) {
    ReadOnlyCollection<GridViewDataColumn> groupedColumns = aspxGridView1.GetGroupedColumns();
    for(int i = groupedColumns.Count - 1; i >= 0; i--) {

asp-net-mvc-grid-create-report-based-on-grid-layout/CS/E4755/Models/MVCxGridViewState.cs#L12

csharp
Columns = new GridViewDataColumnStateCollection(gridView.VisibleColumns);
GroupedColumns = new GridViewDataColumnStateCollection(gridView.GetGroupedColumns());
TotalSummary = new System.Collections.ObjectModel.Collection<MVCxSummaryItemState>();

asp-net-web-forms-grid-create-report-based-on-grid-layout/VB/WebApplication1/ReportHelper.vb#L59

vb
If aspxGridView1.GroupSummary.Count > 0 Then
    Dim groupedColumns As ReadOnlyCollection(Of GridViewDataColumn) = aspxGridView1.GetGroupedColumns()
    For i As Integer = groupedColumns.Count - 1 To 0 Step -1

asp-net-mvc-grid-create-report-based-on-grid-layout/VB/E4755/Models/MVCxGridViewState.vb#L69

vb
Columns = New GridViewDataColumnStateCollection(gridView.VisibleColumns)
GroupedColumns = New GridViewDataColumnStateCollection(gridView.GetGroupedColumns())
TotalSummary = New System.Collections.ObjectModel.Collection(Of MVCxSummaryItemState)()

See Also

ASPxGridView Class

ASPxGridView Members

DevExpress.Web Namespace