How to pass json data to report

2 Answers 879 Views
.NET Core DataSource JSON Report Designer (standalone) Report Parameters Report Viewer - HTML5
Siva
Top achievements
Rank 1
Iron
Siva asked on 27 Mar 2024, 11:02 AM
currently we are using webservice datasource to generate a report but i want to change this datasource from webservicedatasource to jsondatasource, when i manually put the json in inline, its working perfectly but how to pass the data from programatically , as of now we are using telerik.reportserver.httpclient dll and createdocumentdata model to send an data to report but i could not see any fields available in the model to accept json data. Anyone help on this and its a large report it has lot of tables , list ,fields etc

2 Answers, 1 is accepted

Sort by
1
Momchil
Telerik team
answered on 01 Apr 2024, 07:03 AM

Hi Siva,

One way to pass the JSON data to the report is to add a report parameter of type string and bind its value to the DataSource.Source property of each data item that uses your JSON data source.

The following Knowledge Base article provides additional information about this approach.

How to set the content of JsonDataSource through report parameter

I hope this option works for you.

Best Regards,
Momchil
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.
Leo
Top achievements
Rank 1
commented on 02 Dec 2024, 12:59 PM

Hey,

We’re using the method you’ve described.

I’m trying to implement logic where a report parameter checks a data source field for the value 0. This initially seems to work as expected. However, when I change the JSON data for the parameter value (which is passed to the data sources), the conditionals don’t update accordingly. Instead, the report still reflects the conditionals based on the original data.

The approach from (https://www.telerik.com/forums/report-desginer---hide-a-panel-in-telerik-report-designer-based-on-table-data#5892541) works, but as mentioned, it doesn’t seem to adapt when the JSON value of the report parameter changes. The report continues to use the original mapping instead of updating to the new data.

Any advice on resolving this issue?




This is the binding of a table, the parent of the table is a panel with no data source.
My original goal is to hide the panel when a value from the data source is zero. Which worked with the mentioned approach from the link I have sent.
This works, but as I said, when the json value of a report parameter changes I still see the conditionals that apply for the original data sources & not for the changed data thats get passet to the data sources.
Momchil
Telerik team
commented on 04 Dec 2024, 01:08 PM

Hello Leo,

My understanding of your scenario is as follows. You use the same JSON data source both for your table and for the available values of the parameter that checks a certain data source field for the value 0. You also have an extra string parameter you use to update the source of the table's data source through a binding, as described in the How to Set the Contents of a JsonDataSource through a Report Parameter article. Is this correct?

Assuming I got the scenario right, the reason the parameter that checks for the value 0 does not reflect the updated data is that report parameters do not support bindings, and the source of its available values cannot be updated the same way the source of the table is updated. In practice, the approach from the article I linked above does not update the main JSON data source but it updates the specific data items it is applied to, which explains why the parameter is left out.

With this in mind, it will be difficult to combine the approach from the How to Set the Contents of a JsonDataSource through a Report Parameter article and the approach from your other forum question - Report Designer - Hide a Panel in Telerik Report Designer Based on Table Data in Reporting.

Here are some alternatives I can suggest in this scenario.

  • Instead of passing the dynamic JSON through a report parameter, make it accessible through an endpoint in your application and get the data using a WebServiceDataSource.

Please, look into these options and let me know what you think.

1
Siva
Top achievements
Rank 1
Iron
answered on 01 Apr 2024, 10:12 AM

Hi Momchil 

I have already tried this , while configuring the jsondatasource i cant select the parameter value to it, and it only accepts inline json data or external json file.

 

And also i tried to map the json in to parameter, but i cant use the value in my textbox fields, because in textbox does nt have datasource property, in that document its not clear.

 

Can anyone let me know if any option is there.

Momchil
Telerik team
commented on 03 Apr 2024, 11:21 AM

Hi Siva,

You are correct, the source of the JSON data source accepts only inline JSON data and external JSON files.

The workaround binds the source of the JSON data source on the data item level at runtime. For example, if we have a table that uses a JSON data source and we want to change the data of the table based on a parameter value, we need to add a binding in the table's Bindings property.

To illustrate this, I am attaching a demo solution that passes JSON data to a report from a controller. Please, examine the attached solution as well as the report inside it and let me know if any questions arise.

Tags
.NET Core DataSource JSON Report Designer (standalone) Report Parameters Report Viewer - HTML5
Asked by
Siva
Top achievements
Rank 1
Iron
Answers by
Momchil
Telerik team
Siva
Top achievements
Rank 1
Iron
Share this question
or