-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4658311
By: tommasofin
If I handle the onSelect event for a Tree componet I can retrieve the selected items with tree.getSelectedItems().
I need to get the last selected item (the one who fired the event). There is a way to get that in ZK?
Unfortunately tree.getSelectItem() give me only a random selected item, not the one I click...
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4661208
By: jebberwocky
Dear tommaso
I tried that tree.getSelectedItem(). I gives the one I click on.
Testing cod:
<window title="tree demo" border="normal">
<tree id="tree" width="90%" rows="5">
<treecols sizable="true">
<treecol label="Name"/>
<treecol label="Description"/>
</treecols>
<treechildren>
<treeitem id="t1">
<treerow>
<treecell label="Item 1"/>
<treecell label="Item 1 description"/>
</treerow>
</treeitem>
<treeitem id="t2">
<treerow>
<treecell label="Item 2"/>
<treecell label="Item 2 description"/>
</treerow>
</treeitem>
<treeitem id="t3" label="Item 3"/>
</treechildren>
</tree>
<button>
<attribute name="onClick" >
alert(tree.getSelectedItem().getId());
</attribute>
</button>
</window>
Could you provide your code?
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4661568
By: tommasofin
Hi,
the problem is when you have a tree with multiple selection. You will never know which treeitem is the last selected/deselected, because the tree.getSelectedItem() always return the first selected item. This is a ZK limit because you can't handle the onClick event of treeitem, treerow, treecell...
Try this:
<window title="tree demo" border="normal"> <tree checkmark="true" multiple="true" id="tree" width="90%" rows="5"> <attribute name="onSelect" > alert(self.getSelectedItem().getId());
</attribute>
<treecols sizable="true">
<treecol label="Name"/>
<treecol label="Description"/>
</treecols>
<treechildren>
<treeitem id="t1">
<treerow>
<treecell label="Item 1"/>
<treecell label="Item 1 description"/>
</treerow>
</treeitem>
<treeitem id="t2">
<treerow>
<treecell label="Item 2"/>
<treecell label="Item 2 description"/>
</treerow>
</treeitem>
<treeitem id="t3" label="Item 3"/>
</treechildren>
</tree>
</window>
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4661619
By: henrichen
May be you can try something like following:
Set current = tree.getSelectedItems();
Set newSelect = current.removeAll(prev); Set prev = current;
Regarding the issue of getSelectedItem() always returning the first one, we follow the spec. of other window systems with multiple selection :)
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4661631
By: henrichen
If you really needs this, please post to feature request. Maybe we can add in SelectEvent a getClickedItem() that will return the last clicked item?
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4661668
By: tommasofin
Ok thanks, I need this because I would like to make a tree that when you select a node propagate the selection in all the node's childrens. You should think to add this mold in the standard tree component too.
Hi,
I have a similar problem. Have you found a solution to get last selected item with multiple selection?
I have found a solution to iterate on selecteditems and get last item; I verified this method get last selected item, but I'm not secure to have always last item.
Thank you. I get what I need now
Asked: 2007-12-04 15:30:29 +0800
Seen: 646 times
Last updated: Oct 08 '16