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.
@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.

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.