PDA

View Full Version : Select event for tree



ewomack
24 Mar 2011, 7:42 AM
The following code works great for select events on list views and populating contiguous panels:



Ext.ComponentMgr.get('ladebereich').on("click", function (sthis, index, node, e) {
var rec = genres.getAt(index);
var otherPlace = Ext.getCmp('port').findById('yup');
otherPlace.load({ url: 'Engage/' + rec.get("Name").toString() });
});
My question is: what are the equivalent settings for a tree? I'm using a treepanel and want to peform the same function on the nodes, but I haven't yet found a combo that correctly references the store. The issue seems to be with the "genres.getAt" line.

fay
24 Mar 2011, 8:25 AM
The 'click' event on a TreePanel takes the following signature:

( Node node, Ext.EventObject e )

Is it not possible from the Node to determine the record?

ewomack
24 Mar 2011, 8:39 AM
Awesome, Fay, I had to think about it a second, but now I know what you meant by referencing Node.

This:



tree.addListener('click', function (node, event) {
var otherPlace = Ext.getCmp('theViewport').findById('cenPanel');
otherPlace.load({ url: 'Engage/' + node.attributes.text });
});


Returns the node name, calls my MVC controller url and thrusts the string I want over to the "otherPlace."

Cool. Awesome. Splendid. Incredible. [Insert more celebratory hyperboles here].