[{"id":"bf522b5c-b992-4910-b9a3-7d4c6a711342","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"fd92c740-60f2-42bc-b108-133c0baaec15","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"1809c8ed-488b-4fb9-b402-aabe76f0c6d2","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"8aa13734-ff9b-43f5-b44f-de331adbb3d7","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"8faaa45c-575e-4bf0-9034-634fac906bb8","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"56faca6f-14d3-42b0-9706-7df8e339ef70","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"eb780c12-7575-42ef-916d-9d1d66cd0152","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"3918314b-5267-494d-b520-203125daf2a2","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"97d3eeb1-76c4-4c11-bc62-db5413d6819f","tags":[{"product":null,"links":null,"id":"4d7b6a40-ab32-4c71-a381-58f3ffd2653e","name":"new","color":"#ed7422","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"e93f9124-e327-4056-9264-f62378c3ebb5","tags":[{"product":null,"links":null,"id":"4d7b6a40-ab32-4c71-a381-58f3ffd2653e","name":"new","color":"#ed7422","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"90683712-67eb-49c8-96cb-96a228a99d11","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"cf1d42c1-fe4a-4f31-83f7-97c9c7ea9b76","tags":[{"product":null,"links":null,"id":"4d7b6a40-ab32-4c71-a381-58f3ffd2653e","name":"new","color":"#ed7422","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"e6222e08-3705-44f2-9027-b80b72dd3a85","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"5f8d0a4e-e3c5-4f38-91ee-c0d4aa8f116d","tags":[{"product":null,"links":null,"id":"4d7b6a40-ab32-4c71-a381-58f3ffd2653e","name":"new","color":"#ed7422","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"1ab019cd-705f-4371-a3f3-f2925cf92826","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"2ebee074-0c53-44bf-89c4-c0deb0d210f7","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"488a368a-fad1-4022-8e64-03442a912d2c","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"9aa35d28-77db-4dbd-ade0-17163a1782be","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"5a8c2832-0b00-47dc-aa9c-2579f4d9e04c","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"c19b5fcc-8f2a-4f44-9eeb-345cbb4815a6","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"92556861-b9b0-454e-a493-4750e9d90d2c","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"5ca1a599-fa29-4d8a-8cb4-80352932149f","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"7a947fc6-0187-4b9d-b9cc-800def67c597","tags":[{"product":null,"links":null,"id":"4d7b6a40-ab32-4c71-a381-58f3ffd2653e","name":"new","color":"#ed7422","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"b74ce673-ba64-42ea-b124-fc006b6b727e","tags":[{"product":null,"links":null,"id":"4d7b6a40-ab32-4c71-a381-58f3ffd2653e","name":"new","color":"#ed7422","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"a201d71e-7541-4e64-ac8b-3ed714e41a81","tags":[{"product":null,"links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3","name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]},{"id":"9efb31b1-f5f2-4214-a36d-c3415649a7a0","tags":[{"product":null,"links":null,"id":"4d7b6a40-ab32-4c71-a381-58f3ffd2653e","name":"new","color":"#ed7422","productId":"d699a6af-e150-4da3-ab30-25fd97934601"}]}]
        
(Showing Draft Content)

Get Started With Drill Down Reports

Introduction

A drill-down report enables switching from a comprehensive data view down to a more detailed one. It assumes a hierarchical structure of the data visualization. Thus, a report reader can expand a parent item in the hierarchy so that its child items appear. In ActiveReportsJS you can build such a report using Table or Tablix data regions.


In this tutorial, we build the Category Sales report from the ground up, providing experience with the typical report designing process. By the end, you will be able to do the following:

  • Create a new report

  • Bind the report to the GraphQL API

  • Create a table data region

  • Group the data within the table to create a hierarchical data visualization

  • Apply formatting to the table rows and columns

  • Display summary fields for multiple levels of the data hierarchy

  • Setup drill-down navigation for the data hierarchy

  • Use the Galley mode of the report viewer

Upon completion of all tutorial steps, the final report will look like this: live demo.

Prerequisites

The following content assumes that you have the Standalone Report Designer running. Visit the tutorial for detailed information. A stable internet connection is also required to access the Demo Data Hub.

Creating a New Report

In the standalone report designer, click the File menu and select the Continuous Page Layout template for a newly created report. Click anywhere on the gray area around the report layout to load the report properties in the Properties panel. In the Margins section, set the Style property to Narrow to change the report page margins size.

Expand to watch creating a new report in action

CreatingNewReport

Data Binding

Data binding establishes a connection between a report and the data it displays. This tutorial uses the MESCIUS Demo Data GraphQL API, which replicates the well-known Northwind database. It contains the sales data for a fictitious company called Northwind Traders, which imports and exports specialty foods worldwide.

Adding Data Source

You can think of the MESCIUS Demo GraphQL API as the "database" that you can connect to using its root URL https://demodata.mescius.io/northwind/graphql, and that accepts GraphQL queries and responds with the JSON data. You can create a Report DataSource that establishes such a "database connection" using the following steps.

  • Open the Data panel of the property inspector and click the Add button

  • In the Data Source editor dialog, type Northwind in the NAME field and https://demodata.mescius.io/northwind/graphql in the ENDPOINT field

  • Click the + icon on the right side of the HTTP Headers section

  • Type Content-Type in the Header field of the newly added Header item

  • Type application/json in the Value field of the same Header item

  • Click the Save Changes button

image

Adding Data Set

A GraphQL Data Set represents the query to the Data Source. For the Category Sales report, we need a single "Sales" query to select order details, including the product and its category information. GraphQL UI displays the prettified version of such a query:

{
  orderdetails {
    product {
      productId
      productName
      category {
        categoryId
        categoryName
      }
    }
    quantity
    unitPrice
    discount
  }
}

Use the following steps to add the Sales data set:

  • Click the + icon near Northwind in the Data panel

  • In the Data Set Editor dialog, type Sales in the NAME field

  • Select the HTTP POST in the Method drop-down

  • Type {"query":"{orderdetails{product{productId, productName, category{categoryId, categoryName}}, quantity, unitPrice,discount}}"} in the Post body

  • Type $.data.orderdetails.* in the Json Path field

  • Click the Validate button

  • Ensure that the DataBase Fields section displays [7 items] text

  • Click the + icon on the right side of the Calculated Fields section

  • Type salesAmount in the Field Name field of the newly added item

  • Type {quantity * unitPrice * (1-discount)} in the Value field of the same item

  • Click the Save Changes button

Expand to watch adding the Sales data set in action


Adding Table Data Region

In this tutorial we use the Table Data Region to create the drill down report. There are several ways to add a new table into the report. We will use the regular way and adjust the default table configuration by adding a new column and removing the detail row.

  • Expand the toolbox using the Hamburger menu located on the left side of the toolbar

  • Drag and drop the Table item from the toolbox to the top-left corner of the report page area

  • Click anywhere inside the table so that it displays the columns and rows handlers

  • Right-click the last column handler and select the Column > Insert Column Right item in the context menu

  • Right-click the second row handler and select the Delete item in the context menu

Expand to watch adding the Table Data Region in action


The newly created table has four columns, the header and the footer rows.

Setup Hierarchical Table Grouping

The report that we are building should display the sales total per product category on the topmost data hierarchy level. A report reader should expand this topmost level to display the sales total per product within the given category. To achieve that we group the table by the product.category.categoryId and then by product.productId fields of the Sales data set.

  • Click anywhere inside the table so that it displays the group editor

  • Expand the "Sales" data set in the Data panel using the chevron-down icon

  • Drag and drop the product.category.categoryId field in the group editor

  • Drag and drop the product.productId fields in the group editor

The table now has the header and footer rows for each group. We don't use group footers for the report; therefore, we can remove them:

  • Press the Ctrl button on Windows or Cmd on Mac OS and click the 4th and the 5th row handler of the table

  • Right-click the 4th or 5th row handler and select the Row > Delete Row item in the context menu

Expand to watch grouping Table Data Region in action


Formatting Table Columns

The table we are building should display the Product Category Name in the first column, the Product Name in the second column, and the totals for quantity and sales amount in the third and 4th columns. Based on this information, let's set up columns properties:

  • Click anywhere inside the table to display the columns and rows handlers

  • Click the first column handler and set its Width to 2in in the Property inspector

  • Click the second column handler and set its Width to 2.5in in the Property inspector

  • Click the 3rd column handler, press the Ctrl button on Windows or Cmd on Mac OS, and click the 4th column handlers

  • Set the width of the selected columns to 1.5in in the Property inspector

Expand to watch setting last columns widths in action


Switch to the TEXTBOX tab in the Property inspector. You can now modify the properties of all the table cells of a selected column.

  • Click the first column handler

  • Set the Text Align property to Left

  • Set the Vertical Align property to Middle

  • Expand the Padding editor using the icon on its right side and set the Left Padding property to 16pt

In the same manner, set the following properties for other columns cells:

Property

2nd column

3rd column

4th column

Padding

Left = 8pt

Right = 8pt

Right = 16pt

Vertical Align

Middle

Middle

Middle

Text Align

Default(Left)

Right

Right

Format

Default(Empty)

Default(Empty)

Currency

Expand to watch formatting of the last column in action


Configuring Column Headers

We use the table header row to display headers for displayed fields:

  • Double click the first cell of the first table row and type Category

  • Double click the second cell of the first table row and type Product

  • Double click the third cell of the first table row and type Quantity Sold

  • Double clock the 4th cell of the first table row and type Sales Amount

  • Click the first row handler and set its Height to 0.5in in the Property inspector

  • Switch to the TEXTBOX tab in the Property inspector. You can now modify the properties of all the cells of the selected row

  • Set the Background Color property to #f7f7f7

  • Expand the Border Style editor using the icon on its right side and set the Top Border Style and Bottom Border Style properties to Solid

  • Set the Border Color property to #e6e6e6

  • Set the Text Color property to #3da7a8, and the Font Weight to Bold

Note: this step and the next three ones are very similar to formatting columns in the previous step, so we don't show the animation here. You can review the one on the last step to watch how rows and columns formatting in action.

Configuring Category Group Header

The table will generate one group header row, marked with the [1 icon, per each product category. We now format this row and add summary values for quantity and sales amount per category.

  • Click anywhere inside the table to display the columns and rows handlers

  • Click the second row handler

  • Switch to the ROW tab in the Property inspector

  • Set the Height property to 0.4in

  • Switch to the TEXTBOX tab in the Property inspector. You can now modify the properties of all the cells of the selected row

  • Set the Border Width property to 0.25pt

  • Expand the Border Style editor using the icon on its right side and set the Bottom Border Style properties to Solid

  • Set the Border Color property to #e6e6e6

  • Click the field selector of the first cell of the second row and choose the {[product.category.categoryName]} item in the drop-down menu

  • Double click the third cell of the second row and type {Sum(quantity)}

  • Double click the 4th cell of the second row and type {Sum(salesAmount)}

Configuring Product Group Header

The table will generate one group header row, marked with the [2 icon, per each product within a given category. We now format this row and add summary values for quantity and sales amount per product.

  • Click anywhere inside the table to display the columns and rows handlers

  • Click the third row handler

  • Switch to the ROW tab in the Property inspector

  • Set the Height property to 0.4in

  • Switch to the TEXTBOX tab in the Property inspector. You can now modify the properties of all the cells of the selected row

  • Set the Border Width property to 0.25pt

  • Expand the Border Style editor using the icon on its right side and set the Bottom Border Style properties to Dotted

  • Set the Border Color property to #e6e6e6

  • Double click the first cell of the third row and remove the existing text

  • Click the field selector of the second cell of the third row and choose the {[product.productName]} item in the drop-down menu

  • Double click the third cell of the third row and type {Sum(quantity)}

  • Double click the 4th cell of the third row and type {Sum(salesAmount)}

We will use the table footer to show the grand total values for quantity and sales amount across the table.

  • Click anywhere inside the table to display the columns and rows handlers

  • Click the 4th row handler

  • Switch to the ROW tab in the Property inspector

  • Set the Height property to 0.5in

  • Switch to the TEXTBOX tab in the Property inspector. You can now modify the properties of all the cells of the selected row

  • Set the Background Color property to #f7f7f7

  • Expand the Border Style editor using the icon on its right side and set the Top Border Style properties to Solid

  • Set the Border Color property to #e6e6e6

  • Set the Font Weight property to Bold

  • Double click the third cell of the 4th row and type {Sum(quantity)}

  • Double click the 4th cell of the 4th row and type {Sum(salesAmount)}

Adding Table Header

We now add one more table header row to display a heading text.

  • Click anywhere inside the table to display the columns and rows handlers

  • Right click the first row handler and select the Row > Insert Row Above item the drop-down menu

  • Click the handler of the newly selected row and set its Height property to 0.8pt in the Property Inspector

  • Switch to the TEXTBOX tab in the Property inspector

  • Set the Text Color property to #3da7a8, Font Size to 22pt, Font Weight to Bold, and the Vertical Align to Middle

  • Expand the Padding editor using the icon on its right side and set the Left Padding property to 16pt

  • Click the first cell of the first row, press the Ctrl button on Windows or Cmd on Mac OS, and click the 2nd, 3rd, and 4th cells on the same row

  • Right click on the selection and select the Cells > Merge Cells item in the drop-down menu. The row now has a single cell that occupies four columns

  • Double click the merged cell and type Sales By Category

Expand to watch cell merging and setting the table header text in action


Adding Drill Down

The report we are building should display sales by category by default and allow the report reader to expand the category to explore sales by product within the given category. We could achieve such an outcome by setting the dynamic visibility of the Product grouping:

  • Click anywhere inside the table to display the group editor

  • Click the [2 Table1_productproductId1 in the list of groups

  • Set the Hidden property to True

  • Select the TextBox4 in the Toggle Item drop-down. TextBox4 displays the category name. As the result of this setup, the Product group instances will dynamically show and hide if a report reader clicks the expand or collapse icon that appears near each category.

Expand to watch setting drill down in action


Using the Galley Mode for Preview

You can now preview the report output and expand collapse product categories using the + icon on the left side of a category name. You can click the rightmost button, called Galley Mode, on the report viewer toolbar. This button switches the viewer mode to display the unpaginated output that is suitable for reading drill-down reports.

Expand to watch report preview in Galley Mode in action


The final version of report is available at the demo web-site.