ActiveReports 14
ActiveReports 14 User Guide / How To / Page Report/RDL Report How To / Manage Data / Group Data
In This Topic
    Group Data
    In This Topic

    In a page report and RDL report, you can set grouping to organize data in your reports. The most common grouping scenario is to create groups by fields or expressions in a data region.
    Depending on the data region you select, you can group data in one of the following ways:

    To group in a data region

    Detail Grouping is useful when you do not want to repeat values within the data on display in the report.

    1. From the Visual Studio toolbox, drag and drop a Table data region onto the design surface.
    2. With the Table selected on the report, under the Properties Window, click the Property dialog link to open the Table dialog > Detail Grouping page.
    3. In the Detail Grouping page, under Group on enter the expression on which you want to group the data. For e.g., =Fields!YearReleased.Value

      Note: A default group name like Table1_Detail_Group1 appears under Name, until you set the grouping expression under Group On, after which you can modify the group name.
    4. Under the Document map label, you can optionally set a label to add the item to the document map. See Document Map for further information.
    5. Under Parent group, you can optionally set the parent group for a recursive hierarchy.
    6. Click OK to close the dialog.
    7. Drag and drop fields onto the Table data region and go to the preview tab to see grouped data.
       

    Tip: You can filter, set page breaks or set visibility for your grouped data in the other tabs of the Table-Detail Grouping page.

    To group in a FixedPage

    In a Page Report, you can group your data on the fixed page. A group set on the fixed page, applies to the entire report including the controls within the report. Therefore, once you set grouping here, you may decide not to group individual data regions.

    Use the following steps to understand grouping on a fixed page. These steps assume that you have already added a Page Report template, connected it to a data source and created a dataset. See Quick Start and Connect to a Data Source for further information.

    Note: This topic uses the Movie table in the Reels database. By default, the Reels.mdb file is located in [User Documents folder]\GrapeCity Samples\ActiveReports 14\Data folder.
    1. Right-click the gray area outside the design surface and select Fixed Layout Settings or with the fixed page selected, under the Properties Window, click the Property dialog link to open the FixedPage dialog.
    2. On the Grouping page, in the General tab, under Group on enter the field name or expression on which you want to group the data. For example, =Fields!YearReleased.Value.
      Note: A default group name like FixedPage1_Group appears under Name, once you set the group. To modify the group name, add a field name or expression under Group on to enable the Name option and enter a new name.
    3. Under the Document map label field, you can optionally set a label to add the item to the document map.
    4. Click OK to close the dialog.
    5. Drag and drop a data region, like a Table onto the design surface and set data inside its cells.
    6. Go to the Preview Tab to view the result. You'll notice that the data appears in groups sorted according the YearReleased field on each report page.
       

     

    Detail Grouping

    Detail grouping is available in the List and Table data regions. It is useful when you do not want to repeat values within the details. When you set detail grouping, the value repeats for each distinct result of the grouping expression instead of each row of data.

    For example, if you use the Movie table of the Reels database to display movie titles by year without setting detail grouping, you see each year as many times as there are movies from that year.

    If you set detail grouping to =Fields!YearReleased.Value, each year appears only once.

    Note: If the detail grouping expression you use results in a value that is distinct for every row of data, MovieID for example, you will see no difference in the results.

    Recursive Hierarchies

    If you want to display parent-child relationships in your data, you can create a recursive hierarchy. To do this, you need a unique ID field for the child group and an ID field for the parent group.

    For example, if you have pulled data from the Reels database using the following SQL query:

    SQL Query
    Copy Code
    SELECT EmployeePosition.*, Employee.*, Employee_1.PositionID AS ManagerPosition FROM Employee AS Employee_1 RIGHT JOIN (EmployeePosition INNER JOIN Employee ON EmployeePosition.PositionID = Employee.PositionID) ON Employee_1.EmployeeID = Employee.ManagementID;

    You can set Detail Grouping in a Table data region using the =Fields.Item("EmployeePosition.PositionID").Value field, and the =Fields!ManagerPosition.Value field as the parent group to display parent-child relationships in your data.

    Note: You can use only one group expression when you set a parent group.

    Level Function

    To better visualize data in a recursive hierarchy, you can use the Level function. This function indents text and further clarifies the relationships between parent and child data. To do this, you set an expression in the Padding - Left property of the text box you want to indent.

    For example, in a Table data region, for the recursive hierarchy example above, you can set the following expression in the Padding - Left property of the text box that contains the Title to indent values according to levels:

    =Convert.ToString(2 + (Level()*10)) & "pt"