-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Problem: I am working with ZK. Make a leaf node as tree-node and adding a leaf node to it.
My Solution I copy a target-leaf-node object and make it tree-node and then I add another dragged leaf-node to it. Then I remove the target leaf-node as it's not needed anymore.
Issue
My issue is that I am adding the newly created tree-node with leaf-node at the root level. Although I am able to get the path of the target leaf-node, where I want to create a new tree node, But I couldn't find any method in ZK which could help me there.
MyCode
Contact parentContact = parent.getData();
Contact contact = newNodes[0].getData();
parentContact.setCategory(parentContact.getName());
parentContact.setName(null);
TreeNode<Contact> treeNode = new ContactTreeNode(parentContact,new ContactTreeNode[] {});
parent.getModel().getRoot().insert(treeNode, index); //partially works
int[] path = parent.getModel().getPath(parent);
for(int p: path){
System.out.println( p);
}
treeNode.getChildren().add(new ContactTreeNode(contact));
parent.removeFromParent();
thanks.
When I print path, it's obvious different for each node, but for reference it's like it.
0 0 1
I want to create a tree node on above path. Hope you could help me on this.
thanks
first I can't see a connection between the title and the content of your post, So I'll just concentrate on the content.
I am not entirely sure what you try to achieve so before I try to provide the wrong example can you please confirm I understood you correctly:
Do you want to replace an existing leaf-node in a tree with a tree-node that is not a leaf? And want to make sure it is inserted at the same position? Or what do you need the path for? Does ContactTreeNode extend DefaultTreeNode?
did you have a look at the dynamic tree example ?
Asked: 2013-07-01 07:49:21 +0800
Seen: 35 times
Last updated: Jul 03 '13