I have this code in javascript:
var viewer = new window.Stimulsoft.Viewer.StiViewer(
null,
"StiViewer",
false
);
var report = new window.Stimulsoft.Report.StiReport();
const { data: reportData } = await GetRequestFromStore(
this.state.reportDate,
this.state.storeId
);
var json = {
DataSet: reportData.requestItems,
};
var dataSet = new window.Stimulsoft.System.Data.DataSet("JSON");
dataSet.readJson(json);
report.regData("JSON", "JSON", dataSet);
report.loadFile(this.state.reportName);
report.dictionary.variables.getByName(
"requestDate"
).valueObject = this.state.jalaaliReportDate;
viewer.report = report;
viewer.renderHtml("viewer");
and this design of data source in stimulsoft designer
everything works well. But I want to pass multiple json object array to the report. something like this one.
How can I pass Items object array and Descriptions object array to the report in code. Thank you.
DataSet With Two Tables solved my problem. I have combined the two JSON object arrays into one JSON object and register the dataset.
now, reportData is like:
let reportData = {
items: [],
descriptions: [],
};
and dataSet Design in Stimulsoft designer is:
and this part of code worked for me.
var viewer = new window.Stimulsoft.Viewer.StiViewer(null, "Viewer", false);
var report = new window.Stimulsoft.Report.StiReport();
const { data: reportData } = await GetRequestFromStore(
this.state.reportDate,
this.state.storeId
);
var dataSet = new window.Stimulsoft.System.Data.DataSet("DS1");
dataSet.readJson(JSON.stringify(reportData));//one JSON object
//this line of code added,too.
report.dictionary.databases.clear();
report.regData("DS1", "DS1", dataSet);
//this line of code is also required.
report.dictionary.synchronize();
report.loadFile(this.state.reportName);
report.dictionary.variables.getByName(
"requestDate"
).valueObject = this.state.jalaaliReportDate;
viewer.report = report;
viewer.renderHtml("viewer");