I was able to bind a JSON data to dictionary of the report designer using below code.
Code: Select all
var designer = new Stimulsoft.Designer.StiDesigner();
// Create the report designer with default options and show it in this place
var report = new Stimulsoft.Report.StiReport();
report.load(designData.designJson);
//Dataset created
var dataSet = new Stimulsoft.System.Data.DataSet("test");
dataSet.readJson(JSON.stringify(designData.designModel));
report.regData(dataSet.dataSetName, "Test Data", dataSet);
report.dictionary.connect(false);
report.dictionary.synchronize();
designer.report = report;
designer.onSaveReport = function (event) {
var jsonStr = event.report.saveToJsonString();
var obj = {
id : designData.id,
name: event.fileName,
designJson: jsonStr
}
$.ajax({
url: '/save',
method: 'POST',
data: JSON.stringify(obj),
contentType: 'application/json',
dataType: 'json',
success: function (data) {
if (data.code == 200) {
alert("Ok");
}
}
});
event.preventDefault = true;
}
}
});
- root
- root_products
- code
- id
What I need to do is to define captions for these fields for user to see and understand them correctly. I have written some loops for to change them;
Code: Select all
for (var t = 0; t < dataSet.tables.count; t++) {
var _columns = dataSet.tables.getByIndex(t).columns;
for (var i = 0; i < _columns.count; i++) {
if (_columns.getByIndex(i).caption == "timestamp") {
_columns.getByIndex(i).caption = "Date";
}
}
}