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

Processing Group Rows

  • 3 minutes to read

Group Rows and Group Levels

When grouping is applied, group rows organize data into a tree. Group rows are virtual objects. They do not exist in the grid’s data source. Group rows are automatically created when data grouping is applied to combine records with identical values within grouping columns. Ungrouping data automatically removes group rows. Data rows are displayed at the bottommost hierarchy level, and can be accessed by expanding group rows.

Group rows are uniquely identified by their handles. Group row handles are negative (starting from -1), determining the order in which group rows appear within a View according to the sorting and filtering settings. Refer to the Identifying Rows and Cards topic for more information.

GroupLevels

Method Description
GridControl.IsGroupRowHandle Gets whether a row handle corresponds to a group row.
GridControl.GetRowLevelByRowHandle, GridControl.GetRowLevelByVisibleIndex Obtains the grouping level at which a row (group or data row) resides.

Get Group Row Info

Method Description
GridControl.GetGroupRowValue Returns a value of the specified group row in the specified grouping column.
GridControl.GetGroupSummaryValue Returns the specified group summary value displayed within the specified group row.

Iterate Through Child Rows

To iterate through the child rows belonging to a group row, use the following methods:

Method Description
GridControl.GetChildRowCount Returns the number of child rows (group or data) contained within the specified group row.
GridControl.GetChildRowHandle Returns the handle of the row contained within the specified group row, at the specified position.
GridControl.GetParentRowHandle Returns the handle of the group row that owns the specified group or data row.

Example: How to Obtain the Number of Group Rows Displayed within a View

This example shows how to obtain the total number of group rows displayed within a view.

The total number of visible rows is returned by the DataControlBase.VisibleRowCount property. The GridControl.GetRowHandleByVisibleIndex method is used to obtain the processed row’s handle by its position within the view. The GridControl.IsGroupRowHandle method is used to identify whether the processed row is the group row.

using DevExpress.Xpf.Grid;

// ...
private int GetVisibleGroupRowCount(GridControl grid) {
    int count = 0;
    for (int i = 0; i < grid.VisibleRowCount; i++) {
        int rowHandle = grid.GetRowHandleByVisibleIndex(i);
        if(grid.IsGroupRowHandle(rowHandle))
            count++;
    }
    return count;
}

Custom Group Display Text

Member Description
GridControl.CustomGroupDisplayText Allows you to replace the default text within group rows. You can use methods listed in the Obtain and Set Cell Values in Code topic to obtain the required column values and set the DisplayText property to a string value you want to display.
GridColumn.GroupValueTemplate, GridViewBase.GroupValueTemplate Allows you to specify a template that defines the group row’s appearance.