This content has been marked as final.
Show 2 replies
-
1. Re: How can expand the new node just added
chicochen Jul 15, 2007 8:43 AM (in response to chicochen)It's ok now!
public void expandNode(MyTreeNode node) { ArrayList<Long> path = new ArrayList<Long>(); while (node != null) { path.add(node.getNodeid()); node = (MyTreeNode) node.getParent(); } Collections.reverse(path); path.remove(0); // dont expand rootnode, it is not displayed for (int i = 0; i < path.size(); i++) { ArrayList<Long> list = new ArrayList<Long>(); for (int n = 0; n <= i; n++) { list.add(path.get(n)); } ListRowKey key = new ListRowKey(list); try { ((HtmlTree) tree).queueNodeExpand(key); } catch (IOException e) { e.printStackTrace(); } } }
-
2. Re: How can expand the new node just added
bm97 Feb 1, 2008 4:50 AM (in response to chicochen)Thanks, it works.
But, when you don't want to get the first child of the node expanded, remove the deepest node too.public final void expandNode(AbstractTreeNode node) { final ArrayList<Object> path = new ArrayList<Object>(); while (node != null) { path.add(node.getNodeId()); node = (AbstractTreeNode) node.getParent(); } // ADDED path.remove(0); //dont expand first child // ADDED Collections.reverse(path); path.remove(0); // dont expand rootnode, it is not displayed for (int i = 0; i < path.size(); i++) { final ArrayList<Object> list = new ArrayList<Object>(); for (int n = 0; n <= i; n++) { list.add(path.get(n)); } final ListRowKey key = new ListRowKey(list); try { ((HtmlTree) this.tree).queueNodeExpand(key); } catch (final IOException e) { e.printStackTrace(); } } }