Hi,
So what we are wanting to try to achieve is self service reporting. This means that what we would like to present to the user is something that is easy to read. This involves displaying datasources and fields which have descriptive labels in Pascal case but with spaces between the words. For the below examples I have removed the spaces from the fields and datasource names, however, this is something we would like to be able to achieve through whatever means you suggest.
An example of the type of data we would be working with is as follows:
Code: Select all
{
"employeeDetails": [
{
"id": 1,
"firstName": "Bill",
"surname": "Smith",
"employeeDepartments": [
{
"id": 10,
"employeeId": 1,
"code": "SAL",
"name": "Sales"
},
{
"id": 11,
"employeeId": 1,
"code": "IT",
"name": "Information Technology"
}
]
},
{
"id": 2,
"firstName": "Mary",
"surname": "Jane",
"employeeDepartments": [
{
"id": 12,
"employeeId": 2,
"code": "SAL",
"name": "Sales"
},
{
"id": 13,
"employeeId": 2,
"code": "Admin",
"name": "Administration"
}
]
}
]
}
We can quite easily use "report.regData" and "report.dictionary.synchronize()" to automatically link everything up and make all the fields and the relationships available in the designer. From a functional standpoint this works without issue, however, the result is not great from a self service reporting perspective. There are underscores in the table names of child tables and there is an added relationId which I believe is used as part of the automatic linking, which we would like to avoid. See code snippet and screenshot below:
Code: Select all
var options = new Stimulsoft.Designer.StiDesignerOptions();
var designer = new Stimulsoft.Designer.StiDesigner(options, "StiDesigner", false);
options.appearance.fullScreenMode = false;
var report = new Stimulsoft.Report.StiReport();
var dataSet = new Stimulsoft.System.Data.DataSet("DataSet");
var data = <SEE JSON LISTED ABOVE>
dataSet.readJson(data);
report.dictionary.databases.clear();
report.dictionary.dataSources.clear()
report.regData(dataSet.dataSetName, "", dataSet);
report.dictionary.synchronize();
designer.report = report;
designer.renderHtml("content");
The attachment Automatic DS Sync.png is no longer available
We have tried to manually synchronize the report dictionary in an attempt to remove the relationId and underscores. The has the correct appearance in the designer, but, when the data is previewed, there is no data in the "EmployeeDepartments" table of the datasource (if we don not attempt to establish relationships). If we do attempt manually set relationships, we are presented with an error in preview mode. Even if we do not attempt to remove the relationId and underscores but just manually syncronize (the table is then named "EmployeeDetails_EmployeeDepartments"), we get the same issues. See code snippet (the commented out lines make the desired modifications) and screenshots below:
Code: Select all
var options = new Stimulsoft.Designer.StiDesignerOptions();
var designer = new Stimulsoft.Designer.StiDesigner(options, "StiDesigner", false);
options.appearance.fullScreenMode = false;
var report = new Stimulsoft.Report.StiReport();
var dataSet = new Stimulsoft.System.Data.DataSet("DataSet");
var data = <SEE JSON LISTED ABOVE>
dataSet.readJson(data);
report.dictionary.databases.clear();
report.dictionary.dataSources.clear()
report.regData("EmployeeDetails", "EmployeeDetails", dataSet);
for (var index in dataSet.tables.list) {
var data = dataSet.tables.getByIndex(index);
var tableNames = data.tableName;
//if (tableNames.includes("_")) {
// var arr = tableNames.split("_");
// tableNames = arr[1];
//}
var dataSource = new Stimulsoft.Report.Dictionary.StiDataTableSource( "EmployeeDetails",tableNames);
for (var index in data.columns.list) {
var dataColumn = data.columns.list[index];
//if (dataColumn.columnName != "relationId") {
dataSource.columns.add(new Stimulsoft.Report.Dictionary.StiDataColumn(dataColumn.columnName, dataColumn.columnName, dataColumn.columnName));
//}
}
report.dictionary.dataSources.add(dataSource);
}
var dataRelation = new Stimulsoft.Report.Dictionary.StiDataRelation("MyRelation", "MyRelation", "MyRelation", report.dictionary.dataSources.getByName("EmployeeDetails"),
report.dictionary.dataSources.getByName("EmployeeDetails_EmployeeDepartments"), ["id"], ["employeeId"]);
report.dictionary.relations.add(dataRelation);
designer.report = report;
designer.renderHtml("content");
- Automatic DS Sync.png (17.06 KiB) Viewed 3349 times
The attachment Manual DS Error.png is no longer available
I don't know if the issue is with the method we are using or if there is a bug with the control, however, it would be great if you could provide some example code that is able to correctly manually set up the datasource such that we don't see the "relationId" fields and parent table prefix on child tables. Also, could you please give some guidance on displaying the tables and fields with spaces in the interface. Is it a matter of not using spaces in the name and then setting separate display text for the item?