我用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");并在stimulsoft中进行数据源的设计

一切都运行得很好。但我希望将多个json对象数组传递给报表。像这样的东西。

如何在代码中将Items对象数组和Description对象数组传递给报表。谢谢。
发布于 2021-01-19 05:26:03
DataSet With Two Tables解决了我的问题。我已经将两个JSON对象数组组合成一个JSON对象,并注册了dataset。
现在,reportData是这样的:
let reportData = {
items: [],
descriptions: [],
};

Stimulsoft designer中的dataSet设计是:

这部分代码对我来说是有效的。
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");https://stackoverflow.com/questions/65771513
复制相似问题