Registering a JSON Data for the Report Template
Наши примеры проектов и шаблоны отчётов помогут Вам разобраться в основах работы с нашими продуктами.This example shows how to render the report using the external JSON data. First, you need to create the report object of the
As data storage you can use the
На скриншоте ниже Вы можете увидеть результат выполнения данного кода:

StiReport type, then load the report template file by calling the loadFile() method.As data storage you can use the
DataSet object. This object contains the data tables and rows needed for the report. To load JSON data from file into DataSet, you can use the readJsonFile() method. To register a data in the report is the regData() method. This method receives a data source name, data source alias and data object such as a DataSet:
<script type="text/javascript">
// Create a new report instance
var report = new Stimulsoft.Report.StiReport();
// Load report from url
report.loadFile("../reports/SimpleList.mrt");
// Create new DataSet object
var dataSet = new Stimulsoft.System.Data.DataSet("Demo");
// Load JSON data file from specified URL to the DataSet object
dataSet.readJsonFile("../reports/Demo.json");
// Remove all connections from the report template
report.dictionary.databases.clear();
// Register DataSet object
report.regData("Demo", "Demo", dataSet);
// Render report with registered data
report.renderAsync(function () {
document.write("Complete.<br>");
document.write("Rendered pages count: " + report.renderedPages.count);
});
</script>На скриншоте ниже Вы можете увидеть результат выполнения данного кода:
