Adding Groups to Table and Crosstab Items
Add groups to a data item when you want to display your data in a visual hierarchy, align multiple data items to show different views of the same data, or to calculate totals.
You can create both nested groups and adjacent groups. Within a data item, you can create multiple row groups and column groups.
Typically, you define groups automatically as you work with data regions. However, you can add your own groups. The process of adding groups varies based on the type of data region. In a Table, Crosstab or List items, drag data source fields to the Row/Column Fields area. Right-click an existing group to add parent, child or adjacent groups. By definition, the details group is the innermost group and can only be added as a child group. Right-click an existing group to delete it. Rows and columns on which to display group values are automatically added for you. For more information, see Working with Table article.
Add a parent or child row/column group to a Table data item using Report Designer
- Drag a data source field from the Data Explorer
- Drop the field above or below the group hierarchy using the guide bar to place the group as a parent group or a child group to an existing group.
The group is added with a default name, group expression, and sort expression that is based on the field name.
Add an adjacent row/column group to a Table data item
- In the Group Explorer group pane, right-click a group that is a peer to the group that you want to add. Click Add Group, and then click Adjacent Before or Adjacent After to specify where to add the group. The Table Group dialog box opens.
- Click New button.
- In the group expression, type an expression, select a data source field or create a new expression. The group is added with a default name RowGroup or ColumnGroup respectively.
- Click OK.
- Right-click the group, and then click Group Properties.
- In Name, type the name of the group.
- In Grouping property, type or select a simple expression, or click the
<Expression>
option to create a new group expression. - Click New to create additional expressions. All expressions you specify are combined using a logical AND to specify data for this group.
-
To apply sorting to the group, follow these steps:
- Click the Sorting ellipsis.
- Click New.
- Type or select an expression by which to sort the data.
- From the Direction column drop-down list, choose the sort direction for each expression. ASC sorts the expression in ascending order. DESC sorts the expression in descending order.
-
To apply filtering to the group, follow these steps:
- Click the Filters ellipsis.
- Click New.
- In Expression, type or select the expression for the field to filter. To open the Edit Expression Dialog, select the
<Expression>
option. - In the Operator box, select the operator that you want the filter to use to compare the values in the Expression box and the Value box.
- In the Value box, type the expression or value against which you want the filter to evaluate the value in Expression.
Click GroupKeepTogether to specify the keep together options.
- Click BookMarkID to set a BookMark for this group.
- Click OK.
A new group is added to the grouping pane in the Group Explorer and a row or column on which to display group values is added to the Table data item on the design surface.
Add a details group to a Table data item using Report Designer
- In the Group Explorer group pane, right-click a group that is the innermost child group. Click Add Group, and then click Child Group. The Table Group dialog box opens.
- Leave the expression blank - a details group has no expression.
- Select Show detail data.
- Click OK.
- Right-click the group, and then click Group Properties.
- In Name, type the name of the group.
- In Grouping property, type or select a simple expression, or click the
<Expression>
option to create a new group expression. - Click New to create additional expressions. All expressions you specify are combined using a logical AND to specify data for this group.
-
To apply sorting to the group, follow these steps:
- Click the Sorting ellipsis.
- Click New.
- Type or select an expression by which to sort the data.
- From the Direction column drop-down list, choose the sort direction for each expression. ASC sorts the expression in ascending order. DESC sorts the expression in descending order.
-
To apply filtering to the group, follow these steps:
- Click the Filters ellipsis.
- Click New.
- In Expression, type or select the expression for the field to filter. To open the Edit Expression Dialog, select the
<Expression>
option. - In the Operator box, select the operator that you want the filter to use to compare the values in the Expression box and the Value box.
- In the Value box, type the expression or value against which you want the filter to evaluate the value in Expression.
Click GroupKeepTogether to specify the keep together options.
- Click BookMarkID to set a BookMark for this group.
- Click OK.
A new details group is added as a child group in the Grouping pane in the Group Explorer, and the new group displays the details group icon.
Edit a row or column group in a Table data item using Report Designer
- In the Report Designer, select the Table data item. The Grouping pane in the Group Explorer displays the row and column groups.
- Right-click the group, and then click Group Properties.
- In Name, type the name of the group.
- In Grouping property, type or select a simple expression, or click the
<Expression>
option to create a new group expression. - Click New to create additional expressions. All expressions you specify are combined using a logical AND to specify data for this group.
-
To apply sorting to the group, follow these steps:
- Click the Sorting ellipsis.
- Click New.
- Type or select an expression by which to sort the data.
- From the Direction column drop-down list, choose the sort direction for each expression. ASC sorts the expression in ascending order. DESC sorts the expression in descending order.
-
To apply filtering to the group, follow these steps:
- Click the Filters ellipsis.
- Click New.
- In Expression, type or select the expression for the field to filter. To open the Edit Expression Dialog, select the
<Expression>
option. - In the Operator box, select the operator that you want the filter to use to compare the values in the Expression box and the Value box.
- In the Value box, type the expression or value against which you want the filter to evaluate the value in Expression.
Click GroupKeepTogether to specify the keep together options.
- Click BookMarkID to set a BookMark for this group.
- Click OK.
Delete a group from a Table data item using Report Designer
- In the Group Explorer group pane, right-click the group, and then click Delete Group.
-
In the Delete Group dialog box, select one of the following options:
- Delete group and related rows and columns Choose this option to delete the group definition and all related rows that display group data. For the details group, if the same row belongs to both detail and group data, only the detail data rows are deleted.
- Delete group only Choose this option to keep the structure of the Table data item the same and delete only the group definition.
Click OK.
Adding a group to Table data item programatically
Telerik.Reporting.TableGroup group1 = new Telerik.Reporting.TableGroup();
group1.Name = "ProductID1";
group1.Groupings.Add(new Telerik.Reporting.Grouping("=Fields.ProductID"));
// If you need to filter the members of the group, apply filtering
group1.Filters.Add(new Telerik.Reporting.Filter("=Fields.ProductID", Telerik.Reporting.FilterOperator.Equal, "=10"));
// If you need to order the members of the group, apply sorting
group1.Sortings.Add(new Telerik.Reporting.Sorting("=Fields.ProductID", Telerik.Reporting.SortDirection.Asc));
Telerik.Reporting.TextBox textBox1 = new Telerik.Reporting.TextBox();
table1.Items.Add(textBox1);
group1.ReportItem = textBox1;
table1.RowGroups.Add(group1);
Dim group1 As New Telerik.Reporting.TableGroup()
group1.Name = "RowGroup1"
group1.Groupings.Add(New Telerik.Reporting.Grouping("=Fields.ProductID"))
' If you need to filter the members of the group, apply filtering
group1.Filters.Add(New Telerik.Reporting.Filter("=Fields.ProductID", Telerik.Reporting.FilterOperator.Equal, "=10"))
' If you need to order the members of the group, apply sorting
group1.Sortings.Add(New Telerik.Reporting.Sorting("=Fields.ProductID", Telerik.Reporting.SortDirection.Asc))
Dim textBox1 As New Telerik.Reporting.TextBox()
table1.Items.Add(textBox1)
group1.ReportItem = textBox1
table1.RowGroups.Add(group1)