All
I have a simple TreeGrid and I want to be able to dynamically create a parent node and then link children under that node when they are received from the server.
So when I receive a new event from the server I do the following
Step 1. Try and lookup the parent within the tree using the name field.
If I can't find a parent there is not one in the tree so I create one
Then after that I try and add a child node to that parent
getTreeGrid().getData().add(childNode, parentNode);
Now the in the display I see the parent but the child record does not exist.
The only way I have been able to get this working is to create a predefined parent when the tree is build so something like
TreeNode node1 = new TreeNode("2", "1", "Parent");
getDataSource().addData(node1);
So 2 is the nodeId and 1 is what is should link to.
The I change all child nodes to link to id 2.
Is it possible to create a tree without a parent and dynamically create the parents?
I have a simple TreeGrid and I want to be able to dynamically create a parent node and then link children under that node when they are received from the server.
So when I receive a new event from the server I do the following
Step 1. Try and lookup the parent within the tree using the name field.
Code:
TreeNode parentNode = this.display.getTreeGrid().getData().find("Name", parentId);
Code:
if(parentNode == null) { String nodeId = "RC:"+Random.nextDouble(); parentNode = new ExecutionTreeNode(nodeId, "1", parentId); getDataSource().addData(parentNode); getTreeGrid().getData().add(parentNode, "1"); }
getTreeGrid().getData().add(childNode, parentNode);
Now the in the display I see the parent but the child record does not exist.
The only way I have been able to get this working is to create a predefined parent when the tree is build so something like
TreeNode node1 = new TreeNode("2", "1", "Parent");
getDataSource().addData(node1);
So 2 is the nodeId and 1 is what is should link to.
The I change all child nodes to link to id 2.
Is it possible to create a tree without a parent and dynamically create the parents?