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:
- Create toggle item in Tablix, which allow user to do Expand/Collapse action
- 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.
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).
Right click on StateProvinceName group in Grouping pane and Properties from popup menu.
Go to Visibility tab in Group Properties dialog and here we check Display can be toggled by this report item.
On picture bellow there are shown possible options you can set when managing Expand/Collapse functionality.
- For Expand/Collapse lets define toggle item. From select box lists EnlishCountryRegionName, it is text box we will use for Expand/Collapse functionality.
- Show – if we would like to have group expanded by default let’s leave it checked
- Hide – hides group by default.
- Show or hide based on an expression – I will explain in more detail in next posts.
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 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.
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.
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.
After clicking on Australia item you expand all data hidden under Australia region group.
In next post we extend our solution by parametrized Collapse/Expand group.