Creating a new Data Connection from code
Our sample projects and report templates can help you learn the basics of working with our products.A report can be connected to a data source entirely from code, without editing the template dictionary.
Preparing the data. Read or create the data source, register it in the report dictionary, synchronize the schema, and render with the supplied records.
A
Preparing the data. Read or create the data source, register it in the report dictionary, synchronize the schema, and render with the supplied records.
@Component({
selector: "creating-new-data-connection-from-code",
imports: [Viewer],
template: `<sti-viewer [report]="report"></sti-viewer>`
})
export class CreatingNewDataConnectionFromCode {
report: Stimulsoft.Report.StiReport;
constructor() {
this.report = new Stimulsoft.Report.StiReport();
this.report.loadFile("Reports/SimpleList.mrt");
this.report.dictionary.clear();
var database = new Stimulsoft.Report.Dictionary.StiJsonDatabase("Demo", "Data/Demo.json");
this.report.dictionary.databases.add(database);
this.report.dictionary.synchronize();
}
}A
StiJsonDatabase is created with a name and a path to the JSON file, added to dictionary.databases, and dictionary.synchronize() rebuilds the data schema so the report can bind to it.