Page 1 of 1

Changing a DataSource Ident at runtime

Posted: Wed Jun 12, 2019 7:02 pm
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

Re: Changing a DataSource Ident at runtime

Posted: Wed Jun 12, 2019 10:05 pm
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

Re: Changing a DataSource Ident at runtime

Posted: Thu Jun 13, 2019 1:14 pm
by Lech Kulikowski
Hello,

Thank you for the provided information.