The scenario is as follows:
We have a custom datasource adapter which we add programatically to the editor. In the code for that data source we have around 5 tables. Some of these tables have related data.
We have a process function that handles the datasource requests to provide the schema and data as per below
Code: Select all
const schema = {
success: true,
types: {
Task: {
id: 'string',
'domain.id': 'string',
'domain.id.name': 'string',
name: 'string',
description: 'string',
parent: 'string',
'assignee.id': 'string',
'assignee.displayName': 'string',
'createdBy.id': 'string',
'createdBy.displayName': 'string',
deadline: 'datetime',
finsihedAt: 'datetime',
createdAt: 'datetime',
updatedAt: 'datetime',
taskNumber: 'string',
priority: 'string',
estimatedEffort: 'int',
actualEffort: 'int',
progress: 'int',
status: 'string',
colour: 'string',
tags: 'array',
'counters.notes': 'int',
'counters.attachments': 'int',
'counters.subtasks': 'int',
'counters.completedSubtasks': 'int',
'counters.checklistItems': 'int',
'counters.completedChecklistItems': 'int',
'schedule.start': 'datetime',
'schedule.end': 'datetime',
'context.type': 'string',
'context.id': 'string'
},
User: {
userId: 'string',
userName: 'string'
},
Domain: {
id: 'string',
name: 'string',
description: 'string',
goals: 'object',
parent: 'string',
pathToTLD: 'array',
role: 'string',
tld: 'string',
subdomains: 'array',
tags: 'array'
}
}
}
const process = async ({ command, queryString, connectionString }, callback) => {
if (command === 'RetrieveSchema') return callback(schema)
if (command === 'RetrieveData') {
const data = await getData(queryString, connectionString)
callback(data)
return
}
return callback()
}
The task and domain tables have a relation to associate the domain the task is in to the domain details in the domain table.
When a user wants to use this datasource, they add it from the list of datasources and they provide an id in the connection string of the domain they would like the task data for. So the data source can retrieve the tasks from the api. It also retrieves the domains table containing the details of all the domains the tasks might be in.
I found a post outlining how to had a relationship to a dataset like below, but this needs to happen on the actual dataset on the report. So would require there to be a data set already added to the report.
Code: Select all
var dataRelation = new Stimulsoft.Report.Dictionary.StiDataRelation("Relation", "Relation", "Relation", report.dictionary.dataSources.getByName("root_scopeOfWorks"), report.dictionary.dataSources.getByName("root_scopeOfWorks_scope"), ["id"], ["headerId"]);
report.dictionary.relations.add(dataRelation);
1) predefine the relationships in the datsource (schema) itself so when it is added and data fetched, like it pulls the fields from the schema it would already have the relatsionships
or
2) automatically setup the relations at the point in time when the datasource is added to the report, ie through the 'process' function above or something?
Any assistance is greatly appreciated