PDA

View Full Version : TreePanel function on leaf



macistina
15 Jul 2009, 6:06 AM
Hi all,
I have a problem with a treePanel.
I create my treePanel using a static json obj. The structure is correct, but I want associate a function to the leafs of my tree.
I attached the screen.
Using the code below I call the function by the "dir" of the tree.
Could you help me?
for(var i = 0; i<json.length; i++) {
this.root.appendChild(json[i]);
this.root.childNodes[i].on('click',util.callRedirectUrl,this);
}

saJoshua
15 Jul 2009, 6:15 AM
try adding a "click" listener to your json[i] config:

return json like :


var yourHandler = function(node, e){
// do something
}

{
text : 'Package Details',
listeners : {
click : yourHandler
}
}

Animal
15 Jul 2009, 6:19 AM
That would be on the TreePanel config.

macistina
15 Jul 2009, 7:10 AM
saJoshua,
doesn't work also inserting the listener in json[i] config.
I wrote a private message inserting all code, so you can see the general situation.
Regards,

Animal
15 Jul 2009, 7:17 AM
MMMM?

One listener goes on the TreePanel. Simples!

macistina
20 Jul 2009, 3:56 AM
Thank's I solved my problem using listener on treePanel!!!!!