Changing a DataSource Ident at runtime

Stimulsoft Dashboards.JS discussion
Post Reply
csntang
Posts: 2
Joined: Wed Jun 12, 2019 6:56 pm

Changing a DataSource Ident at runtime

Post by csntang »

I most everything else working except this one last piece (which works if I change the .Ident manually)

I am looking to change the Dictionary.DataSources.Ident from "StiPostgreSQLSource" to "StiDataTableSource" so I can load JSON into the report using the following method:

Code: Select all

  let reportJSON ={
  "reporting_base_crosstab_data" : [{
      "name": "Who knows?"
      "connectionsmade" : "25",
      "date" : "02-02-2019",
      "interactionsmade": "34"
      } ] };

  var dataSet = new SSoft.System.Data.DataSet("Demo");
  dataSet.readJson(reportJSON);
  report.regData("Demo", "Demo", dataSet);
If I manually change the Ident to "StiDataTableSource" in the .mrt file, the report loads. I am working on programmatically changing the Ident property before rendering the report.

Thanks,

Mike
Last edited by csntang on Wed Jun 12, 2019 10:07 pm, edited 1 time in total.
csntang
Posts: 2
Joined: Wed Jun 12, 2019 6:56 pm

Re: Changing a DataSource Ident at runtime

Post by csntang »

I believe I figured this out. Typing out the problem helped me to see it. I needed to remove the existing DataSources with a

Code: Select all

 //I was missing this:
  report.dictionary.dataSources.clear();

  ds = new SSoft.Report.Dictionary.StiDataTableSource('reporting_base_crosstab_data', 'reporting_base_crosstab_data', 'reporting_base_crosstab_data');
  ds.columns.add(new SSoft.Report.Dictionary.StiDataColumn("name", "name", "name");
  {...all other columns...}
  report.dictionary.dataSources.add(ds);"));


Like when you update the Databases themselves

Code: Select all

  report.dictionary.databases.clear();
Thanks!!!

Mike
Lech Kulikowski
Posts: 6237
Joined: Tue Mar 20, 2018 5:34 am

Re: Changing a DataSource Ident at runtime

Post by Lech Kulikowski »

Hello,

Thank you for the provided information.
Post Reply