View Full Version : How can I get the selected node in a treepanel ?

28 May 2012, 5:25 PM
I have a treepanel populated through a tree store, from my controller I'm trying something like:

treepanel = Ext.getCmp('assigned-vehicles-panel').getSelectionModel().getSelection();

And the array returns always empty, I don't know if it's because my nodes are inside the root and the root is hidden, so, can someone help me on this ??
thank you.


28 May 2012, 11:21 PM
Probably because you are listening to a click event of panel's element , and this event fires before selection model process the selection, you can check by adding a delay. So better if you use select event, IMO is more suitable unless you need to do sth special with the click event

29 May 2012, 5:27 AM
Of course I want to do something special with it, I need to get the id property of the selected node to send it as part of an ajax request, I'll try adding a very small delay, but seems very tricky and I don't like using more delays... Thanks a lot.

29 May 2012, 8:33 AM
Instead of using a delay I managed to store the value in a hidden field to post proccess. That's all, but in the future I won't be able to work around this way but I'll have plenty of time to solve it.
Thanks anyways.

29 May 2012, 10:05 AM
:), ok, I didn't suggest you to use as a solution a delay but to use the 'select' event, the delay was only for you to check and to understand better what are you doing ;)