Telerik blogs

The Web Report Designer’s Crosstab component lets you drill down into detail data when you need it—all you have to do is turn it on.

You can create interactive reports using Progress Telerik Report Designers, including a crosstab report that lets you expand and collapse your detail data as you need it. If you’re using the Web Report Designer embedded in an application, you can even create those reports right in the application where you’ll use them.

In a previous post I showed how to add a crosstab to a report. In this post, I’ll show how to expand and display the groups in that crosstab so you can have the detail data when you need it and hide it the rest of the time.

A table showing product data organized into groups by category. The first column of the table shows category names and spans multiple rows (i.e. all the rows for each product in the category). The second column shows a list of product names with columns to the right showing information about the product (e.g. unit price, quantity in stock, etc.). Each category ends with a row showing no text in the product name column and totals in each of the numeric columns. All of the category columns are collapsed, except for the condiments category which is expanded to show a row for each product in the category

The good news is that the interactivity you want is built into the crosstab component—you just need to do two things: activate the interactivity and set the crosstab’s initial display.

Activating Crosstab Interactivity

To activate the built-in interactivity provided by the crosstab you need to set two things:

  • The site for your interactivity: Where you’ll click to trigger expanding/collapsing your detail
  • The target: What part of your crosstab you want to expand/collapse

Typically, the site where you’ll tie your interactivity is the field you added to your crosstab’s Row Group or Column Group (in my case, I added the CategoryName field to the crosstab’s Row Group). In a Row Group, that field will be in the leftmost column of the crosstab (in a Column Group, it will be in the top row of the crosstab).

For the sample crosstab report I’m using for my case study, that means that I want to be able to click on the Category textbox in my crosstab’s leftmost column to trigger expanding/collapsing data.

Typically (again) the target—the fields you want to expand and collapse—will be the fields you added to the crosstab’s Detail Values. In my case, that’s my ProductName, UnitPrice, UnitsInStock and UnitsOnOrder fields. In a Row Group, only the subtotals for the fields will be displayed when the group is collapsed but all the detail rows will be displayed when the group is expanded (in a Column Group, the columns will be hidden or displayed). For my case study, when I click on the CategoryName column, I want to display the detail data for each product in the category.

That takes longer to explain than to do. First, you need to select the textbox in your crosstab that you want to click on to expand/collapse your data (for me, that’s the CategoryName textbox in the crosstab’s leftmost column). Then, in the panel on the right, you need to expand the Action section and, then, in the Type dropdown list at the top of the section, select the Toggle visibility option.

Your final step is to specify that you want to make the details section of the crosstab visible/invisible. That’s a two-step process:

  1. In the Toggle targets dropdown list, select the option labeled “detail (TableGroup)”.

A screenshot of the report designer with the panel on the right. The report designer has a crosstab displayed. The first row of the crosstab consists of headings and the first column has the heading CategoryName. The second row begins with a large textbox with the formula = Fields.CategoryName. That textbox is circled. The panel on the right shows an area called Action. That section has been expanded to display a dropdown list labeled Type. The dropdown list has been set to Toggle Visibility. Below that is the label Toggle targets which has a dropdown list containing the text “detail (Table Group)”. To the right of this dropdown list is a plus sign.

  1. Click the plus sign to the right of the dropdown list to add that detail section to your list of toggled targets.

Hint: As that implies, you can have make as many groups visible or invisible as you want: Just add more groups to your list of targets.

You’ve now enabled your crosstab’s interactivity … but you’re probably not done yet.

Setting the Initial State

If your goal is, initially, to have a big-picture view of your data that you can use to determine what detail you want to see … well, then you’ll probably be disappointed if you preview your report at this stage. By default, the initial view of your report displays the detail data for all the rows in your crosstab.

While you can collapse the groups you’re not interested in, the rest of the groups will still be showing all their detail rows (in the following screenshot, for example, the Condiments group has been collapsed but all the other groups are still expanded).

The crosstab report with categories expanded to show the products in each category with the exception of the Condiments category – that category is just a single row with subtotal data. There is an icon in each category field – a plus sign for the expanded rows and a minus sign for the collapsed row (the Condiments category.

To meet your goal, all you have to do is change the default, initial view of the crosstab from “detail expanded” to “detail collapsed.”

Hint: You don’t have to keep closing the tab in your browser that’s displaying your report in order to make changes to your report. If you want, you can just return to the tab where you’re editing the report in the report designer to make your changes, leaving your preview tab open. When you’re done making changes, click on the Save option in the hamburger menu in the upper left corner of the report designer before switching back to your preview tab. When you get back to your preview, press F5 to refresh the report and see your changes.

To change the initial view of your crosstab, switch to the Explorer tab on the left side of the designer and find your crosstab (it will be called something like “crosstabn”—e.g., crosstab1).

Under Row Groups for your crosstab, find the field you dropped in the Row Group section back when you created your crosstab (in my case, that’s the CategoryName field). Under that field, select the group called detail (the process is similar if you used a Column Group instead of or in addition to a Row Group).

Now, in the panel on the right, uncheck the Visible checkbox.

The report designer with the crosstab in the designer window. In the panel on the left, the Explorer tab is selected showing a treeview of the report’s components. A node labelled crosstab4 is expanded, underneath it the Row Groups node is expanded and underneath it the detail node is selected. In the panel on the right of the designer, a checkbox at the bottom of the panel labeled Visible is unchecked -the empty checkbox is circled

You’re done—if you now preview your report, you’ll see that all the detail sections are collapsed by default (in this screenshot, you can see that I’ve only got the Condiments group expanded).

The crosstab report with one row for each category, except for the Condiments category row which is expanded to show all the products in the category. The product column is displaying the name of a product in all of subtotal rows and the total row.

Hint: And, if you do add multiple groups to your targets, they don’t all need to have the same “initial state.” By default, any other group you add to your list of targets will have its Visibility setting checked. As a result, when the user clicks on the textbox you chose, that second group will have its visibility toggled off—it will disappear while the detail section appears. Effectively, you’ve given the user the ability to switch between two different views.

Cleaning up

There’s more you can do but, regardless of what additional changes you make, you’ve now got a report that will let you see the big picture when the report first displays while letting you dive into the detail when you need to. And, if you’ve created this from the Web Report Designer embedded in your application then this report will be waiting for you when you come back to your application.

Embedded Reporting?

Progress Telerik Reporting provides all the tools you need to embed the rich, interactive reports your users need in order to analyze and understand their data right into your users’ applications (including letting your users export the results into more than 15 formats, either to distribute or integrate with other analysis tools). Telerik Reporting then lets you go further and empower your users with a fully functional Web Report Designer to create the reports they want without ever leaving the applications where they’ll use their reports.

You can leverage these easy-to-use tools in both any client-side web application environment (HTML5/JS, Angular, React, Vue or Blazor) and any .NET application (web or desktop: ASP.NET Core, ASP.NET MVC, ASP.NET AJAX, WinForms and UWP).

If you still have not tried it, you can start a free trial to take a closer look. A renowned support service and an array of resources will help you along the way.

Try Now


Peter Vogel
About the Author

Peter Vogel

Peter Vogel is a system architect and principal in PH&V Information Services. PH&V provides full-stack consulting from UX design through object modeling to database design. Peter also writes courses and teaches for Learning Tree International.

Related Posts

Comments

Comments are disabled in preview mode.