| | | | Browse by category |
Question
How to populate an IlvSDMModel
programmatically, how to create subgraphs.
Answer
The IlvSDMModel
interface provides methods for creating and adding new nodes to the model, which allows it to be modified programmatically within an application. Here is a summary of the relevant IlvSDMModel
methods:
createNode()
createLink()
addObject()
setFrom()
setTo()
- ...
The attached sample illustrates this capability. Right-clicking in the view adds new nodes to the model; if the click occurs over one of the topmost nodes in the hierarchy, the new node is added as a child of the clicked item.
You can download the sample here.
In the sample, the SubGraph
renderer is activated to reveal the parent-child hierarchy of the SDM model. Since the rendering of a node changes depending on whether the node has child nodes or not (if it has child nodes, it will be rendered as a submanager), it is necessary to add this setting to the CSS to take this change into account:
SubGraph {
leafToContainerEnabled : "true";
}
Note: the model can be changed only if the isEditable()
method from the IlvSDMModel
interface returns true
. Refer to the documentation for further details.