|
I am able to find the nodes but I am not finding any values in that. Can you please tell me how to find the values present within EACH NODE that has been added. |
By default, in the node , we only bind the node property values. We cannot bind the HTML content values used in the node. However, by using the node addInfo property you can store the text values. The addInfo property is used to store the additional or custom information of node. After edit the text box and click outside the text box, selectionChange event for the diagram gets fired. In that event get the value of the text box and bind it to the selected node addInfo property. Please refer the below code example
Video demonstration: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Selection-Change-694740211
After add the values in addInfo , you can get the values of the template through node addInfo property.
Note: AddInfo property of node is an object type, you can assign whether array , string , number or any other object type to the node addInfo property
| |
|
After trying a lot I am finding out that for some reason the NG-MODEL is not being applied to the elements within the DIV id="htmlTemplate". But the elements outside the DIV id="htmlTemplate" is working fine. so my guess is Angularjs is working fine but for some reason with syncfusion its failing to read the ng-model values. |
On analyzing the provided code snippet you have set the htmlTemplate as a div element. If we set other than script element means htmlTemplate for the node do not gets visible. If you want to set htmlTemplate for node means then set inside script element. So that only htmlTemplate for node gets visible. We have used your HTML content inside script to show htmlTemplate for node.
| |
|
Also, here I am adding the CONNECTOR between the NODES. I want to know how can I find the SOURCE POINT and DESTINATION POINT of a CONNECTOR once it has been added. I am trying to fire the following function but in that I don't get any info e.connectionChange="connectionChange" |
When you change the source or target point of the connector, connectorSourceChange and connectorTargetChange event gets fired. By using that args element we can find in which node connector gets connected. Through sourceNode and targetNode property of element we can find in which node connector gets connected.
Video demonstration: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Connection-Change1834088193
|
|
var count = 0;
document.getElementById('addNode').onclick = function() {
++count;
var diagram = $("#diagram").ejDiagram("instance");
diagram.model.drawType = { type: "html", templateId: "htmlTemplate",
value:"text" + Number(count) };
var tool = diagram.tool();
diagram.update({ tool: tool | ej.datavisualization.Diagram.Tool.DrawOnce })
}
<script id="htmlTemplate" type="text/x-jsrender">
<div>
<select ng-model="Dynamic.optionValue" class="form-control">
<option class="dropdown-item" value="Option 1" selected> Choose Options</option>
<option class="dropdown-item" ng-repeat="option in options" value="Option 2"> Option 2 </option>
</select>
<input type="text" id="{{:value}}" placeholder="number of objects"></input>
</div>
</script> |
|
function selectionChange(args) {
if(args.state === 'changing' && args.changeType === 'remove') {
node = args.oldItems[0];
} else if (args.state === 'changed' && args.changeType === 'remove') {
debugger
node.addInfo = document.getElementById(node.value).value;
}
}
document.getElementById('values').onclick = function() {
var diagram = $("#diagram").ejDiagram("instance");
for (var i = 0 ; i < diagram.model.nodes.length ; i++) {
console.log("Node AddInfo: -> " + diagram.model.nodes[i].addInfo);
}
} |
|
How can I get the SELECT field value when they are different? Since I am assigning the VALUE for the NODE I can use only for the TEXT field if I want to use for SELECT then should I tried something like this: value:{text:"text"+Number(count),select:"select"+Number(count)}.
If there are 10 fields then I need to assign different values for all 10 fields so wanted some confirmation.
|
In the value property we can able to set an array of string values. In that value field set an Id for the HTML content and bind it in the HTML select and text box Id field. Please refer below code snippet
| |
|
Every time I make an update/change any HTML fields then I should click on the DIAGRAM, right? is there any alternative approach where I can store as soon as they make the change something similar to NG-CHANGE orONBLUR? Because I don't think user would be happy to click every time on DIAGRAM when they make a change. |
Yes, you can use the text box onchange or onBlur event instead of selection change event. After the value gets changed in the text box and out of text box OnBlur event gets triggered. In that event get the diagram selected items through diagram selectionList. After get the selected node , now set the text box value to the node addInfo value.
| |
|
I am assigning my own name to each NODE that is being created for ex: NODE1, NODE2 etc but for some reason when I see in the CONSOLE then I see that some new characters have been automatically appended to the NODE NAME: "Node1LUwp" or "Node2hkIu". Is there a way I can retain the name that I am assigning to the NODE? same for CONNECTOR as well. |
By default, in the diagram , when we drag and drop a node from symbol palette to diagram or draw a node through drawing tools, we have add randomId at last of the node name. Because in the diagram id of the diagram elements should be unique. If we set name for the drawing tools object and draw that object more than in diagram means then object which draw at last only gets displayed in the diagram if we set same name. So to overcome this only we have added a randomId at last of the node name. |