Skip to main content
A newer version of this page is available. .
Tab

ASPxGridView.GetGroupedColumns() Method

Returns a collection of columns involved in grouping.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v19.1.dll

Declaration

public ReadOnlyCollection<GridViewDataColumn> GetGroupedColumns()

Returns

Type Description
ReadOnlyCollection<GridViewDataColumn>

The collection of columns involved in grouping.

Remarks

Data displayed within the ASPxGridView can be grouped by multiple columns. The GetGroupedColumns property provides access to the columns involved in grouping. This property can be used if you need to traverse through the grouped columns to perform operations on them.

To learn more, see Grouping Overview.

Example

This example demonstrates how to save/load the layout data of the grouped and expanded rows during callbacks. Pay attention to the following features:- The Dictionary<string, string> contains grouped grid's layouts saved by the user. This Dictionary is kept in a Session.

- It is possible to load the last saved layout from by clicking the "Load Layout" button.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v10.1, Version=10.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v10.1, Version=10.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.1, Version=10.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>How to save/store ASPxGridView's layout</title>
</head>
<body>
    <form runat="server" id="form1">
    <dx:ASPxGridView ID="grid" runat="server" AutoGenerateColumns="False" ClientInstanceName="grid"
        DataSourceID="SqlDataSource1" KeyFieldName="ProductID" OnCustomCallback="grid_CustomCallback">
        <SettingsPager EllipsisMode="None" PageSize="15">
        </SettingsPager>
        <Columns>
            <dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="0">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="1">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="CategoryID" VisibleIndex="2">
            </dx:GridViewDataTextColumn>
        </Columns>
        <Settings ShowGroupPanel="True" />
    </dx:ASPxGridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT [ProductID], [ProductName], [CategoryID] FROM [Products]">
    </asp:SqlDataSource>
    <dx:ASPxButton ID="buttonLoad" runat="server" AutoPostBack="False" Text="Load Layout">
        <ClientSideEvents Click="function(s, e) {
            grid.PerformCallback();
        }" />
    </dx:ASPxButton>
    <dx:ASPxButton ID="buttonSave" runat="server" AutoPostBack="False" Text="Save Layout">
        <ClientSideEvents Click="function(s, e) {
            callback.PerformCallback();
        }" />
    </dx:ASPxButton>
    <dx:ASPxCallback ID="callback" runat="server" ClientInstanceName="callback" OnCallback="callback_Callback">
    </dx:ASPxCallback>
    </form>
</body>
</html>

The following code snippet (auto-collected from DevExpress Examples) contains a reference 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.

See Also