Creating a new Data Connection from code
Наши примеры проектов и шаблоны отчётов помогут Вам разобраться в основах работы с нашими продуктами.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.