Based on the below json sample, I am trying to define a Telerik report using both a main report and a sub-report, where se second is fed with a subset of the main report json data.
Basically, data flow mimics something like:
Troubles arose on step 4, where I am getting an [Invalid value of report parameter 'jsonData'] error when main report is rendered.
It seems Telerik Report is unable to convert a selected json node field data into a proper string.
For full context:
On both reports:
There is a jsonData report parameter of string datatype;
There is a JsonDataSource defined;
Binding between the string jsonData parameter and main JsonDataSource is based upon:
On main report:
Name, a string representing the company name;
Employes, an object containing the company employes list.
On sub-report:
Again on main-report, I am using the following sub-report parameters mapping:
I am using Telerik Report Designer v15.1.21.716 (Desktop)
It seems that data selector converts json Employes node date into a System.Object[], which is giving me a nice hard time figuring out how to convert it back to a json string.
I have alread extensively searched on documentation, web, ChatGPT and alikes for a valid solution. So far, no luck.
Although I have the most appreciation for anyones effort trying to helping me:
{
"Companies": [
{
"Name": "Company1",
"Employes": [
{
"Name": "Joe",
"Wage": 1000
},
{
"Name": "Jack",
"Wage": 2000
}
]
},
{
"Name": "Company2",
"Employes": [
{
"Name": "Mary",
"Wage": 3000
},
{
"Name": "Mike",
"Wage": 4000
}
]
}
]
}
Indeed, passing the "Employes" object to the "jsonData" parameter of the subreport should not work because the object cannot be converted to a JSON string directly. You have to convert it thru CStr() function.
However, instead of using a parameter to set the data source of the subreport, you can use the binding described in the How to Represent Hierarchical Nested Data KB article.
I also want to mention that in the R3 2022 SP1 release, the DataSource property was added to the SubReport item as well. This makes the approach I suggested above obsolete because it allows you to bind the data source of the subreport directly in the main report. For example:
Property path: DataSource
Expression: = Fields.Employes
In @Julio's provided sample, which allows to inject json node as a sub-report parameter, instead of a direct datasource, you should use following approach.
Property path: jsonData
Expression: = CStr(Fields.Employes)
Solution 1, although does not require an explicit report to sub-report binding, it still needs the following inner binding on the sub-report:
Property path: DataSource
Expression: = ReportItem.Parent is Null ? ReportItem.DataSource : ReportItem.Parent.DataObject.Employes
Solution 2, requires additional binding between the sub-report parameter and its datasource, as stated on the original post.
For further details on this subject, check original Telerik's original post