Hi, I want to bind nodemodel's width height property from out source data class. When I try to bind it like following it is not reflected, how can I solve it ?
Hi Esra,
We have created a sample to bind the height and width of the nodemodel from external data. Diagram can be populated based on the user-defined JSON data (Local Data) by mapping the relevant data source fields. By using the DataManager we can able to bind the diagram from an external datasource. In the datasource’s doBinding bind the height and width of external data to the node’s height and width. Please refer to the below code snippet and sample
|
public Data: any = [ { Name: 'Diagram', fillColor: '#916DAF', height: 150, width: 150, }, { Name: 'Layout', Category: 'Diagram', height: 100, width: 100, }, { Name: 'Tree Layout', Category: 'Layout', height: 75, width: 75, }, { Name: 'Organizational Chart', Category: 'Layout', height: 75, width: 75, }, ];
public data: Object = { //sets the fields to bind id: 'Name', parentId: 'Category', dataSource: new DataManager(this.Data), //binds the data with the nodes doBinding: (nodeModel: NodeModel, data: object, diagram: Diagram) => { // Bind the height and width to node nodeModel.height = (data as any).height; nodeModel.width = (data as any).width; }, }; |
Sample: https://stackblitz.com/edit/angular-frx78t
Regards
Aravind Ravi