[]
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.
Create a new report. By default, you have a blank RDL Report.
Connect to a data source.
Go to the Data tab and click Add.
In the DataSource dialog, provide the following URL as Endpoint for the 'Remote JSON' provider:
https://demodata.grapecity.com/northwind/odata/v1/
Add nested datasets.
Click Add Data Set against the added data source.
In the DataSet dialog > Uri/Path, write the resource name as 'Employees'. This is the parent dataset.
In the Parameters field, click Add Items and enter the following key/value pair to add a child dataset, 'Orders'.
$expand
, Value=Orders
Enter the Json Path: $.value[*]
.
Validate the query to retrieve fields. Note that the Orders dataset is shown in the Nested Datasets field.
Click Save Changes. The 'Orders' dataset is nested within 'Employees' dataset.
See Databinding for information on connecting to data sources and adding datasets.
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.
Drag-drop a List data region from the Toolbox onto the design area.
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.
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.
Add labels and bind the text boxes as described:
Select TextBox1 and enter the text: 'Employee ID:'.
Select TextBox2 and enter the expression: =Fields!EmployeeId.Value
.
Select TextBox3 and enter the text: 'Employee Name:'.
Select TextBox4 and enter the expression: =Fields!FirstName.Value& " " &Fields!LastName.Value
.
Select TextBox5 and enter the text: 'Title:'.
Select TextBox6 and enter the expression: =Fields!Title.Value
.
We will now add the Table data region and bind it to the child data set to display the order details of the employees.
Expand the dataset fields in 'Orders' dataset and enable Select Fields...
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:
With the Table data region selected, set the Data Set Name property to 'Orders'. This data region is bound to the child data set.
Let us add a title in the page header area of our report.
Go to the Report tab on top of the designer and select Add Header option.
Drag and drop a TextBox control in the header area.
Click inside the text box and enter the text 'Employee Orders Report (Master-Detail Report)'.
Note: You may need to resize and reposition the controls on the report to accommodate data, and for a cleaner look.
Set the text alignments using TEXT - Text Align (Left, Right, Center, etc.) and TEXT - Vertical Text Align (Top, Middle, or Bottom) properties.
Set a background color for Page Header using the Background - Color property (#f1f1f1). Set the same background color for the List data region.
Set a font using the Text - Font Family property (Song).
Set the TEXT - Font Size for the text (16pt) and Text - Font Color for the font color (#3da7a8) in page header.
Click Preview to view your report in the final output.
Exit the preview mode by clicking Back on the top left side of the designer.
Click Save to open the Save dialog box. Enter the report name and click Save Report.