Expand collapse groups

Expand, collapse functionality is nice feature of Reporting Services. In this post we use this functionality in connection with Tablix component. Be aware that more SSRS components support this functionality and it is good approach how to make reports and dashboards more user-friendly. It’s also a way how to make top to bottom analysis, since user can get data from totals to details by few clicks.

For practice you can use any of your report where you have Tablix or Matrix component with few groups. Or you go to one of my previous posts where you can download sample grouped report.

Lets have report or similar report as on picture bellow. So we have groups and detail data and our task is to prepare user view per Region Name by default with posibility to go to data on lower group level. In short we have to do 2 steps:

  1. Create toggle item in Tablix, which allow user to do Expand/Collapse action
  2. Hide groups at lower level of group hierarchy to see only Region Name when runing report by default

Lets have report or similar report as on picture bellow.

Sales report
Picture 1 Sales report

To set toggle item, click on group from which you would like to Expand/Collapse data. As you see on picture bellow, we would like to toggle EnglishCountryRegionName, so we have to go to StateProvinceName group property and there set toggle item. It is important that toggle item is textbox outside of the group we would like to Expand/Collapse (otherwise SSRS displays an error when rendering).

Tablix Toggle item
Picture 2 Tablix Toggle item

Right click on StateProvinceName group in Grouping pane and Properties from popup menu.

 Grouping Pane
Picture 3 Grouping Pane

Go to Visibility tab in Group Properties dialog and here we check Display can be toggled by this report item.

Group Visibility
Picture 4 Group Visibility

On picture bellow there are shown possible options you can set when managing Expand/Collapse functionality.

  1. For Expand/Collapse lets define toggle item. From select box lists EnlishCountryRegionName, it is text box we will use for Expand/Collapse functionality.
  2. Show – if we would like to have group expanded by default let’s leave it checked
  3. Hide – hides group by default.
  4. Show or hide based on an expression – I will explain in more detail in next posts.
Group Properties - Group visibility
Picture 5 Group Properties – Group visibility

For our scenario, Group Property dialog should look as on picture bellow. Check Hide, check Display can be toggled by this report item and select Report Item.

Group Properties
Picture 6 Group Properties

Group visibility and toggle item can be set also through Properties

Pane as shown on picture below. Click on Grouping Pane on StateProvinceName group. In Properties Pane set properties in Visibility section, Hidden and ToggleItem.

Properties Pane
Picture 7 Properties Pane

TIP: toggle item sign has “+” character by default. If you would like to change it go to your report item, which you set as toggle. In our case it is textbox EnglishCountryRegionName in the Tablix. In Properties

Pane you can change the default initial state sign trough InitialToggleState property.

Properties Pane Visibility
Picture 8 Properties Pane Visibility

Finally, you should get your Tablix design looks like on the report bellow. Data are collapsed at Region name level. User can go the detail by expand toggle item situated on the left side of the report.

Sales report Collapsed
Picture 9 Sales report Collapsed

After clicking on Australia item you expand all data hidden under Australia region group.

Sales report Expanded
Picture 10 Sales report Expanded

In next post we extend our solution by parametrized Collapse/Expand group.

Leave a Reply

Your email address will not be published. Required fields are marked *