Registering a Data from Code when Rendering a Report on the Server-Side
Our sample projects and report templates can help you learn the basics of working with our products.When rendering server-side, data can be registered through the onBeforeRender event, which runs in the Node.js engine.
Preparing the data. Read or create the data source, register it in the report dictionary, synchronize the schema, and render with the supplied records.
The
Preparing the data. Read or create the data source, register it in the report dictionary, synchronize the schema, and render with the supplied records.
$report = new StiReport();
$report->engine = StiEngineType::ServerNodeJS;
$report->onBeforeRender = '
let dataSet = new Stimulsoft.System.Data.DataSet("Demo");
dataSet.readJson(jsonData);
args.report.dictionary.databases.clear();
args.report.regData("Demo", "Demo", dataSet);
';
$report->process();
$report->loadFile('reports/SimpleList.mrt', true);
$report->render();engine = StiEngineType::ServerNodeJS— renders on the server with the Node.js engine.onBeforeRender— holds JavaScript that runs inside the server-side engine just before rendering.readJson / regData— builds a dataset and registers it with the report exactly as in the browser.
The
onBeforeRender script runs inside the server-side engine just before rendering, letting you attach data to a headless render exactly as you would in the browser.