Hello Syncfusion.
In the Diagram, I have different node types. Some of them are native, another HTML one.
All my nodes have addInfo property, which stores entity data.
In getNodeDefaults method, I detect depending on node type, generate html for the node or not.
node.shape = { type: 'HTML', content: this.getHtmlContent(node) }
#####
getHtmlContent(node: NodeModel) {
// @ts-ignore
let annotation = node.annotations[0].content;
// @ts-ignore
let style = node.style.fill;
// @ts-ignore
let textColor = node.annotations[0].style.color;
this.setNodeIcon(node)
let htmlContent = `<div style="background:${style};display:flex;height:100%;width:100%;">
<div style="width:90%;height:100%;display:table;">
<p style="padding-left:2em;text-align:center;color:white;vertical-align: middle;display: table-cell;">${annotation}</p>
</div>
<div style="display: table; height: 100%;">
<i class="${this.nodeIcon}" aria-hidden style="color: ${textColor}; height: 100%; vertical-align: middle; display: table-cell;">
</i>
</div>
</div>`
return htmlContent;
}
After api/Edit call executed, on callback I update addInfo property for the selected node, and it's own annotation.
async editNode(data) {
//Method to add labels at run time
if(this.currentNodeId !== undefined){
// @ts-ignore
let index = this.diagramInstance.nodes.map(e => e.id).indexOf(this.currentNodeId);
// @ts-ignore
this.diagramInstance.nodes[index].annotations[0].content = data.title;
// @ts-ignore
this.diagramInstance.nodes[index].addInfo.customData.tasktemplate = data;
// @ts-ignore
this.diagramInstance.dataBind();
}
}
Annotations in diagramInstance nodes array are updated, but HTML content is not updated. Only after I reload diagram, HTML nodes get actual data.