首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Javascript中将多个json对象数组传递给模拟软报表

如何在Javascript中将多个json对象数组传递给模拟软报表
EN

Stack Overflow用户
提问于 2021-01-18 17:05:33
回答 1查看 335关注 0票数 0

我用javascript编写了以下代码:

代码语言: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对象数组传递给报表。谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-19 05:26:03

DataSet With Two Tables解决了我的问题。我已经将两个JSON对象数组组合成一个JSON对象,并注册了dataset。

现在,reportData是这样的:

代码语言:javascript
复制
let reportData = {
  items: [],
  descriptions: [],
};

Stimulsoft designer中的dataSet设计是:

这部分代码对我来说是有效的。

代码语言:javascript
复制
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");
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65771513

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档