Registering Data from Code
Our sample projects and report templates can help you learn the basics of working with our products.Data can be registered for a dashboard from code — here two buttons load XML or JSON and rebuild the report with it.
In Angular.
How it works. Each button loads a dataset and re-registers it, so the same dashboard renders from XML or JSON on demand.
In Angular.
@Component({
imports: [Viewer],
template: `
<button (click)="buttonXmlClick()">Register XML Data</button>
<button (click)="buttonJsonClick()">Register JSON Data</button>
<sti-viewer [report]="report"></sti-viewer>`
})
export class Example {
report = Stimulsoft.Report.StiReport.createNewDashboard();
updateReport(dataSet: Stimulsoft.System.Data.DataSet) {
this.report = new Stimulsoft.Report.StiReport();
this.report.loadFile("Dashboards/Orders.mrt");
this.report.dictionary.databases.clear();
this.report.regData("Orders", "Orders", dataSet);
}
buttonXmlClick() {
var dataSet = new Stimulsoft.System.Data.DataSet();
dataSet.readXmlSchemaFile("Data/Orders.xsd");
dataSet.readXmlFile("Data/Orders.xml");
this.updateReport(dataSet);
}
buttonJsonClick() {
var dataSet = new Stimulsoft.System.Data.DataSet();
dataSet.readJsonFile("Data/Orders.json");
this.updateReport(dataSet);
}
}dataSet.readXmlFile / readJsonFile— load a dataset from XML (with its schema) or JSON.dictionary.databases.clear()+regData("Orders", "Orders", dataSet)— drop template connections and bind the loaded data.
How it works. Each button loads a dataset and re-registers it, so the same dashboard renders from XML or JSON on demand.