0

How to rename /add a tree node dynamiclly ?

asked 2009-02-27 07:57:18 +0800

evpole gravatar image evpole
481 2

I have a tree:




<tree model="@{controller.category }" id="tree"
mold="paging" context="treepop">
<treecols>
<treecol label="@{controller.title }" />
</treecols>
</tree>

<menupopup id="treepop"><menuitem label="rename" popup="renamepop"/><menuitem label="add" popup="addpop"/></menupopup>
<popup id="renamepop">enter new name:<textbox id="newname" /><button label="save" id="save1"/></popup>
<popup id="addpop">enter new name:<textbox id="newname" /><button label="save" id="save2"/></popup>



I would like to rename /add a tree node when user right click any node of the tree.
I have seen the demo at :http://www.zkoss.org/smalltalks/zkTreeModel/, it seems have to fire an event like this:

fireEvent(parent,indexFrom,indexTo,TreeDataEvent.INTERVAL_REMOVED);


but class SimpleTreeModel seems don't have this method,and I don't know how to get the "parent" object,it seems to be a ArrayList ,not a Treeitem.but i could only got Treeitem by tree.getSelectedItem().

could anyone please help me ?thanks for any advise!

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2009-03-07 09:49:57 +0800

jdeboer gravatar image jdeboer
36

SimpleTreeModel inherits from AbstractTreeModel so it has a method fireEvent.

To get the parent of your selected item: tree.getSelectedItem().getParentItem()

link publish delete flag offensive edit

answered 2009-03-11 07:19:38 +0800

evpole gravatar image evpole
481 2

hi,jdeoer,thanks for response.

but the parent parameter in fireEvent seems must be an ArrayList ,not a treeitem.so:
fireEvent(tree.getSelectedItem().getParentItem(),indexFrom,indexTo,TreeDataEvent.INTERVAL_REMOVED);

seems not correct.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-02-27 07:57:18 +0800

Seen: 345 times

Last updated: Mar 11 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More