TreeGrid treeGrid = new TreeGrid();
treeGrid.setWidth(300);
treeGrid.setHeight(400);
TreeGridField field = new TreeGridField("Name", "Tree from local data");
field.setCanSort(false);
treeGrid.setFields(new TreeGridField[]{field});
Tree tree = new Tree();
tree.setModelType(TreeModelType.PARENT);
tree.setNameProperty("Name");
tree.setIdField("EmployeeId");
tree.setParentIdField("ReportsTo");
tree.setShowRoot(true);
EmployeeTreeNode root = new EmployeeTreeNode("4", "1", "Charles Madigen");
EmployeeTreeNode node2 = new EmployeeTreeNode("188", "4", "Rogine Leger");
EmployeeTreeNode node3 = new EmployeeTreeNode("189", "4", "Gene Porter");
EmployeeTreeNode node4 = new EmployeeTreeNode("265", "189", "Olivier Doucet");
EmployeeTreeNode node5 = new EmployeeTreeNode("264", "189", "Cheryl Pearson");
tree.setData(new TreeNode[]{root, node2, node3, node4, node5});
tree.setRoot(root);
treeGrid.setData(tree);
treeGrid.draw();
How can I add a new tree node into the treegrid after the treegrid has been created?
treeGrid.setWidth(300);
treeGrid.setHeight(400);
TreeGridField field = new TreeGridField("Name", "Tree from local data");
field.setCanSort(false);
treeGrid.setFields(new TreeGridField[]{field});
Tree tree = new Tree();
tree.setModelType(TreeModelType.PARENT);
tree.setNameProperty("Name");
tree.setIdField("EmployeeId");
tree.setParentIdField("ReportsTo");
tree.setShowRoot(true);
EmployeeTreeNode root = new EmployeeTreeNode("4", "1", "Charles Madigen");
EmployeeTreeNode node2 = new EmployeeTreeNode("188", "4", "Rogine Leger");
EmployeeTreeNode node3 = new EmployeeTreeNode("189", "4", "Gene Porter");
EmployeeTreeNode node4 = new EmployeeTreeNode("265", "189", "Olivier Doucet");
EmployeeTreeNode node5 = new EmployeeTreeNode("264", "189", "Cheryl Pearson");
tree.setData(new TreeNode[]{root, node2, node3, node4, node5});
tree.setRoot(root);
treeGrid.setData(tree);
treeGrid.draw();
How can I add a new tree node into the treegrid after the treegrid has been created?
Comment