PDA

View Full Version : How to load EXT tree in version 3.2



samir_ware
16 Aug 2012, 5:50 PM
Hello all
I am using EXT 3.2 for loading tree . The overall code is as follows.




var treePanel = new Ext.tree.TreePanel({ useArrows : true, autoScroll: true, animate: true, enableDD: true, containerScroll: true, rootVisible : false, loader: new Ext.tree.TreeLoader({ dataUrl: 'data.jsp?tree', preloadChildren: true, requestMethod: 'GET' }), root: { nodeType: 'async', text: 'Ext JS', expanded : true, draggable: false, id: 'treeModel' } });



Though in this case my JSON is having some custom root. The JSON structure is as follows





{"treeModel":[{"id":"Node1","text":"Node 1","leaf":false},{"id":"Node2","text":"Node 2","leaf":false},{"id":"Node4","text":"Node 4","leaf":false}]}

Here I have root as "treeModel" and there is no way I can change this. My tree may be not understanding what is the root because of which tree is not getting rendered. Is there any way I can specify root for my tree ? Is there anything like "reader" for tree ? If it is there can anyone please tell me how to use it.
Thanks in advance
Samir

poojagarg89
23 Aug 2012, 2:44 AM
try this Code may be it'll be of ur help...........!!!



var admin_root= new Ext.tree.TreeNode({
id:"admin_node",
text:"Admin",
expanded:true
});

Ext.app.widgetsLoader = Ext.extend(Ext.ux.XmlTreeLoader, {
processAttributes : function(attr){
if(attr.widget_id){
attr.text = attr.widget_id;
attr.loaded = true;
}
}
});
var widgets_typeLoader =new Ext.app.widgetsLoader({
id:"widgetconf_typeLoader",
dataUrl:'WidgetConfiguration_Tree'
});
widgets_root=admin_root.appendChild(
new Ext.tree.AsyncTreeNode({
text:'Widget Configuration',
// id:'permissions_node',
scope:this,
loader:widgets_typeLoader
})
);

var admin_panel = new Ext.tree.TreePanel({
id: "admin_panel",
// useArrows: true,
autoScroll: true,
title: "",
border:false,
collapsible: false,
autoScroll: true,
rootVisible: true,
lines: true,
singleExpand:true,
root:admin_root,
listeners:{
click:function(node,e)
{}
}
});