[]
You can enter a connection string for the JSON data as an expression and pass values using parameters to set up the data sources dynamically.
Let us create a tabular report where data in the table is fetched from a dynamically built JSON data source.
In the ActiveReports Designer, create a new RDLX report.
Connect to a Data Source
As you create a new report, the Report Data Source dialog appears for you to configure the report data connection. You can also access this dialog by right-clicking the Data Sources node in the Report Explorer and then selecting the Add Data Source option.
In the dialog, select the General page and enter the name of the data source, 'Categories'.
Under Type, select 'Json Provider'.
In the Content tab, set the type of Json data to 'External file or URL'.
In the Select or type the file name or URL field, enter the following URL: https://demodata.mescius.io/northwind/api/v1/Categories
The Connection String tab displays the generated connection string as shown below:
jsondoc=https://demodata.mescius.io/northwind/api/v1/Categories
For more information, see the JSON Provider topic.
Verify the generated connection string by clicking the Validate DataSource icon.
Click OK to save the changes and close the Report Data Source dialog.
Add Dataset
Right-click the added data source and select Add Dataset.
In the Dataset dialog, select the General page and enter the name of the dataset, 'dsCategories'.
Go to the Query tab and enter the following query to fetch the required fields:
$.[*]
In the Report Explorer, right-click the Parameters node and select the Add Parameters option.
In the Report - Parameters dialog box that appears, set the following:
General tab | |
---|---|
Property | Value |
Name | paramCategories |
Data Type | String |
Text for prompting users for value | Select a Category |
Available Values tab (>From query) | |
Property | Value |
Dataset | dsCategories |
Value field | categoryId |
Label field | categoryName |
Order By: Condition | Label |
Order By: Direction | Ascending |
Click OK.
Connect to a Data Source
Add Dataset
Right-click the added data source and select Add Dataset.
In the Dataset dialog, select the General page and enter the name of the dataset, 'dsProducts'.
Go to the Query tab and enter the following query to fetch the required fields:
$.[*]
Click OK.
Update Data Source Connection
Edit the 'Products' data source.
Go to the Content tab, select Expression, and enter the expression in the editor like the following:
="jsondoc=https://demodata.mescius.io/northwind/api/v1/Categories/"+[@paramCategories]+"/Products"
Click OK.