Hey, so I was able to make it work the following way:
In the code of the factory I found the following minified code snipped:
function D(e) {
if ("object" != typeof e || null == e || !(T in e))
throw new Error("Only an ObjectItem can be passed to a template.");
return e[T]
}
where T is ‘Symbol(mxObject)’. The condition which failed was the exactly this one with the Symbol as property. Since you cannot fake these Symbols (they are always unique) I needed to retrieve the original Symbol which got used.
I added a field to the widget state named ‘symbol’:
this.state = {
loadedSubdata: false,
data: [],
symbol: null
}
I then set its value to the first symbol I received from the first datasource property, like so:
const isAvailable = this.props.parent.data.status === 'available';
if (isAvailable && !this.state.loadedSubdata) {
this.state.loadedSubdata = true;
console.log('loading subdata');
this.props.parent.data.items.forEach(i => {
if (!this.state.symbol) {
this.state.symbol = Object.getOwnPropertySymbols(i)[0];
}
...
this.getData(obj);
});
}
Once I receieved the subdata I then was able to mimik an ObjectItem by creating an object with the same structure:
let columns = i.subdata.map(s => {
const subObj = {
id: s._guid,
};
subObj[this.state.symbol] = s;
return factory(subObj);
});
This worked! :)
I hope this helps someone
- Tobias