I don't know if I'm clear.
I want to add a database into the .mrt file using javaScript.
For example for the following code (this is a part of my .mrt file) :
Code: Select all
"Dictionary":{
"DataSources":{
"0":{
"Ident":"StiDataTableSource",
"Name":"databases",
"Alias":"databases",
"Columns":{
"0":{
"Name":"libelle",
"Index":-1,
"NameInSource":"libelle",
"Alias":"libelle",
"Type":"System.String"
},
"1":{
"Name":"libcourt",
"Index":-1,
"NameInSource":"libcourt",
"Alias":"libcourt",
"Type":"System.String"
},
"2":{
"Name":"name",
"Index":-1,
"NameInSource":"name",
"Alias":"name",
"Type":"System.String"
}
},
"NameInSource":"datas.databases"
}
This is a table databases with 3 columns :
- libelle ;
- libcourt ;
- name.
And the datas are in a Json object called datas.databases.
Here is the value of the var datas :
Code: Select all
var datas = { "databases" : [{"libelle":"myLibelle1","libcourt":"myLibCourt1","name":"name1"},{"libelle":"myLibelle2","libcourt":"myLibCourt2","name":"name2"}]}
I want to know if is it possible to add databases using javaScript as for example :
Code: Select all
var myObj1 = {JSON};
var myObj2 = {JSON};
var myObj3 = {JSON};
var report = new Stimulsoft.Report.StiReport();
report.loadFile("test.mrt");
report.dictionary.datasources.add(myObj1);
report.dictionary.datasources.add(myObj2);
report.dictionary.datasources.add(myObj3);
report.render();
I have already tried :
Code: Select all
var datas = { "databases" : [{"libelle":"myLibelle1","libcourt":"myLibCourt1","name":"name1"},{"libelle":"myLibelle2","libcourt":"myLibCourt2","name":"name2"}]};
var dataSet = new Stimulsoft.System.Data.DataSet("datas");
var report = new Stimulsoft.Report.StiReport();
report.loadFile("test.mrt");
dataSet.readJson(datas);
report.regData(dataSet.dataSetName, "", dataSet);
report.render();
But it works only if the json object is already defined in the .mrt file. So
what is the syntax I have to used to defined my json object in the .mrt file ?