PDA

View Full Version : Reading tree nodes



jrcunha
15 Apr 2009, 4:37 AM
Hi guys,

I'm using Ext.tree.TreePanel to display some shortcuts in my app. The user can change the order, create and delete nodes. The nodes are lodaded from the database via AJAX and inserted via ext API.

I need to update the database when the user make modifications on tree layout, but, i don't know how to read the current tree's layout to do this. Any idea?

Regards

20 Apr 2009, 9:06 AM
you figure it out by knowing what the node's parent is and it's position in the hierarchy.

have you tried to look at the node in firebug?

jrcunha
20 Apr 2009, 9:58 AM
Hi jgarcia,

I already solved my problem doing this: In the Ext.tree.TreePanel object creation, i add the following directive:

loader: new Ext.tree.TreeLoader({preloadChildren:true }),

and registered 'enddrag, 'add' and 'remove' events, to call a function to read the nodes:

var root = tree.getRootNode();
var layout = new Arra();
root.cascade( function(node) {
// .....
layout.push(nodeObj);
});

var string = Ext.util.JSON.encode(layout);
// Code to send current layout and update the database

Anyway, thanks for the help.

Best Regards

Junior Cunha