[]
        
(Showing Draft Content)

Master-Detail Report using Nested Data Regions (with nested datasets)

The Master-detail reports are commonly used to display data from nested datasets, which by default have a master-detail relationship.

In this tutorial, we will nest the Table data region within the List data region to display the data from nested datasets. The List data region fetches data from parent dataset, 'Employees' and the Table data region fetches data from child dataset, 'Orders'. To create the nested datasets, use $expand parameter in the parent dataset query, which expands the orders for each employee.

After you complete this tutorial, you will have a report that looks similar to the following.

Bind Data to Report

  1. Create a new report. By default, you have a blank RDL Report.

  2. Connect to a data source.

    1. Go to the Data tab and click Add.

    2. In the DataSource dialog, provide the following URL as Endpoint for the 'Remote JSON' provider:

    https://demodata.grapecity.com/northwind/odata/v1/
    
    1. Click Save Changes.
  3. Add nested datasets.

    1. Click Add Data Set against the added data source.

    2. In the DataSet dialog > Uri/Path, write the resource name as 'Employees'. This is the parent dataset.

    3. In the Parameters field, click Add Items and enter the following key/value pair to add a child dataset, 'Orders'.

      • Key=$expand , Value=Orders
    4. Enter the Json Path: $.value[*].

    5. Validate the query to retrieve fields. Note that the Orders dataset is shown in the Nested Datasets field.

    6. Click Save Changes. The 'Orders' dataset is nested within 'Employees' dataset.
      See Databinding for information on connecting to data sources and adding datasets.

Add List Data Region to the Report

The List data region will be used to display the master record from the parent dataset. It will contain the TextBox controls to display the employee information. It will also contain a Table data region (the nested data region) to display the order details corresponding to each employee. The List data region repeats any report control it contains for every record in the dataset.

  1. Drag-drop a List data region from the Toolbox onto the design area.

  2. With the List data region selected, set the Data Set Name property to 'Employees'. Now, this data region is bound to the parent data set, Employees.

  3. We want employees' id, name, and title information in the master report. To display this information, drag-drop few TextBox controls onto the list and arrange the these text boxes as shown.

  4. Add labels and bind the text boxes as described:

    1. Select TextBox1 and enter the text: 'Employee ID:'.

    2. Select TextBox2 and enter the expression: =Fields!EmployeeId.Value.

    3. Select TextBox3 and enter the text: 'Employee Name:'.

    4. Select TextBox4 and enter the expression: =Fields!FirstName.Value& " " &Fields!LastName.Value.

    5. Select TextBox5 and enter the text: 'Title:'.

    6. Select TextBox6 and enter the expression: =Fields!Title.Value.

Nest a Table Data Region within the List Data Region

We will now add the Table data region and bind it to the child data set to display the order details of the employees.

  1. Expand the dataset fields in 'Orders' dataset and enable Select Fields...

  2. Select the fields required in the table and drag-drop onto the List data region as shown.

    A table with its columns bound to the fields is created inside the List data region. Check that the two data regions are nested from the Explorer as shown:

  3. With the Table data region selected, set the Data Set Name property to 'Orders'. This data region is bound to the child data set.

Add Title

Let us add a title in the page header area of our report.

  1. Go to the Report tab on top of the designer and select Add Header option.

  2. Drag and drop a TextBox control in the header area.

  3. Click inside the text box and enter the text 'Employee Orders Report (Master-Detail Report)'.

Customize the Appearance of Master-Detail Report

Note: You may need to resize and reposition the controls on the report to accommodate data, and for a cleaner look.

  1. Set the text alignments using TEXT - Text Align (Left, Right, Center, etc.) and TEXT - Vertical Text Align (Top, Middle, or Bottom) properties.

  2. Set a background color for Page Header using the Background - Color property (#f1f1f1). Set the same background color for the List data region.

  3. Set a font using the Text - Font Family property (Song).

  4. Set the TEXT - Font Size for the text (16pt) and Text - Font Color for the font color (#3da7a8) in page header.

Preview and Save Report

  1. Click Preview to view your report in the final output.

  2. Exit the preview mode by clicking Back on the top left side of the designer.

  3. Click Save to open the Save dialog box. Enter the report name and click Save Report.