View Full Version : Loading a Tree with an xml which is getting built inside code

14 Jun 2011, 11:56 PM
Hello i want to load a tree with an xml that i am building in the code itself.
So i cant give dataUrl for the loader.

If i copy the xml generated & place in a folder & trying to load my tree with this xml then tree is getting loaded.

But i need to load the tree with xml which is getting built in my code some where in between.

If i need to use Xmlstore then how to get a local xml file ?

var tree=new Ext.tree.TreePanel({
autoScroll: true,
rootVisible: false,
root: new Ext.tree.AsyncTreeNode(),
//loader: treeLoader
//store: compnyStore

16 Jun 2011, 2:14 PM
That all sounds very strange. You'd probably be better off keeping your data in the browser as Ext.data.Nodes and only serializing it to XML when you absolutely have to. By keeping the data unserialized it'd make things like creating your tree much simpler.

Using XmlStore doesn't make sense either. Stores are flat, trees are not.

If you have an XML string then you could parse it using something like this:


It probably doesn't make sense to write your own loader, all you need is something to convert XML to nodes then append those nodes to the tree. The method parseXml() in XmlTreeLoader (http://dev.sencha.com/deploy/ext-3.4.0/examples/ux/XmlTreeLoader.js) shows you how.