broox
28 Jun 2007, 1:41 PM
Is there a way to set a root node from a JSON file?
Currently I have this code:
var tree = new xt.TreePanel(viewEl, {
animate:true,
loader: new xt.TreeLoader({dataUrl:'menuLoader.aspx'}),
enableDD:true,
containerScroll: true
});
var root = new xt.AsyncTreeNode({
text: 'EXT JS',
draggable: false,
id: 'source'
});
tree.setRootNode(root);
tree.render();
root.expand();
I'd really not like to create that root node "EXT JS" like that. It's just an extra, unneeded node.
My JSON contains all of the necessary nodes. It'd be nice if I could select a node that is already in my JSON as the root or something? Or is it possible to just not have a root?
Here's my current test JSON:
[{"text" : "Derek's Pages", "id" : "1", "leaf" : false, "cls" : "folder", "children" : [{"text" : "broox.com", "id" : "2", "href" : "http://www.broox.com", "leaf" : true, "cls" : "file"},{"text" : "Des Moines Alive", "id" : "3", "href" : "http://www.desmoinesalive.com", "leaf" : true, "cls" : "file"},{"text" : "Mitsubishi", "id" : "4", "leaf" : false, "cls" : "folder", "children" : [{"text" : "Eclipse", "id" : "5", "leaf" : true, "cls" : "file"},{"text" : "Lancer", "id" : "6", "leaf" : true, "cls" : "file"}]}]},{"text" : "Show JSON", "id" : "7", "href" : "menuLoader.aspx", "leaf" : true, "cls" : "file"}]
Currently I have this code:
var tree = new xt.TreePanel(viewEl, {
animate:true,
loader: new xt.TreeLoader({dataUrl:'menuLoader.aspx'}),
enableDD:true,
containerScroll: true
});
var root = new xt.AsyncTreeNode({
text: 'EXT JS',
draggable: false,
id: 'source'
});
tree.setRootNode(root);
tree.render();
root.expand();
I'd really not like to create that root node "EXT JS" like that. It's just an extra, unneeded node.
My JSON contains all of the necessary nodes. It'd be nice if I could select a node that is already in my JSON as the root or something? Or is it possible to just not have a root?
Here's my current test JSON:
[{"text" : "Derek's Pages", "id" : "1", "leaf" : false, "cls" : "folder", "children" : [{"text" : "broox.com", "id" : "2", "href" : "http://www.broox.com", "leaf" : true, "cls" : "file"},{"text" : "Des Moines Alive", "id" : "3", "href" : "http://www.desmoinesalive.com", "leaf" : true, "cls" : "file"},{"text" : "Mitsubishi", "id" : "4", "leaf" : false, "cls" : "folder", "children" : [{"text" : "Eclipse", "id" : "5", "leaf" : true, "cls" : "file"},{"text" : "Lancer", "id" : "6", "leaf" : true, "cls" : "file"}]}]},{"text" : "Show JSON", "id" : "7", "href" : "menuLoader.aspx", "leaf" : true, "cls" : "file"}]