TX Text Control Blog

Merging nested repeating blocks in ReportingCloud

Björn Meyer

Blogged by Björn Meyer on August 10, 2017 and tagged with reportingcloud, reporting, asp.net.


Thanks to the data source excerpt file concept, it is very easy to create templates with complex structures such as nested repeating blocks. A data source excerpt file is used to fill the drop-down lists of the template editor with proper merge fields, relations and dummy data for a template preview. A data source excerpt file is not the actual data that is used to merge the template. It helps to design the templates and to insert the proper field names.

In this article, the following .NET classes are used as the data source structure for the ReportingCloud merge process:

Report is the master template which reflects the complete template. In other words, the complete template is merged with the number of rows in this master template. The following code shows the instantiated .NET object that is used:

This object has 1 Sale object which consists of 2 different Item objects. In the template, a list of all Sale items should be visualized as a merge block. Inside this outer merge block, all Item objects should get listed as a nested merge block. The following screenshot shows this structure in the template:

Merging nested repeating blocks in ReportingCloud

But how to insert these blocks in the ReportingCloud template designer?

First, we need to create a serialized JSON string from the object. You can create this string manually or simply serialize this object using the JavaScriptSerializer class:

The results will look similar to this:

In the ReportingCloud Portal, open My Datasource Excerpts and create a new excerpt file by adding a name and pasting the JSON string to the excerpt input. As ReportingCloud expects an array of objects as the data source, enclose the complete string with square brackets.

Merging nested repeating blocks in ReportingCloud

Now, when designing the template in the ReportingCloud template designer, the merge blocks are listed in the available Insert Merge Block drop-down button. In the ReportingCloud Portal, create a new template in the My Templates area. Before editing the template, select the created datasource excerpt file from the available sources and confirm with Edit Template.

Merging nested repeating blocks in ReportingCloud

  1. In the opened template designer, click on sales from the Insert Merge Block drop-down to insert the outer merge block sales.

  2. Set the input position into the block row and add a table row using the right-click context menu.

    Merging nested repeating blocks in ReportingCloud

  3. Set the input position into the newly created table row and choose items from the Insert Merge Block drop-down to insert the nested block items.

  4. In the opened dialog, select the 2 columns price and qty and confirm with OK.

    Merging nested repeating blocks in ReportingCloud

A second nested block has been inserted into the outer block:

Merging nested repeating blocks in ReportingCloud

When previewing this template, the expected results of the nested block are rendered successfully:

Merging nested repeating blocks in ReportingCloud

Test this on your own and create a free trial account today.

 
 
Call us: +1 704-544-7445 (United States)
 
 

Products

Support

Downloads

Corporate

Buy Now

About Text Control

Founded in 1991, Text Control is an award-winning Visual Studio Industry Partner and leading vendor of word processing and reporting components for Microsoft development technologies. The products help thousands of developers add comprehensive word processing functionality to their applications. Text Control is 100% self-owned and independent of all investor decisions. Customers benefit from these years of experience, large user-base, and at the same time, appreciate developing with a mature, reliable product.

SD Times 100SD Times 100SD Times 100SD Times 100SD Times 100SD Times 100Visual Studio 2015 Launch PartnerVisual Studio 2013 Launch PartnerVisual Studio 2012 Launch PartnerVisual Studio Partner