PDA

View Full Version : SOS: Ext.tree.TreePanel +.net+ Json



haoduotnt
16 Aug 2008, 11:56 PM
:(
Extend Ext.tree.TreeLoader


CMS.JsonTreeLoader = function() {
CMS.JsonTreeLoader.superclass.constructor.call(this, {
});
};
var URL = "http://cms.sx.com";

Ext.extend(CMS.JsonTreeLoader, Ext.tree.TreeLoader, {

requestData : function(node, callback){
var _THIS = this;

if (this.fireEvent("beforeload", this, node, callback) !== false) {
var dataStore = new Ext.data.Store({
url: URL+"/DataAccess/Menu/GetJsonMenus.mthd",

/*Return Json String:*/
//[{"ROOT":[{"text":"SystemManager","cls":"x-tree-menu-ct","iconCls":"x-tree-menu-//parent","leaf":false,"bindPanel"
//:"null","expanded":true,"children":[{"text":"ChannnelManager","cls":"x-tree-menu-//ct","iconCls":"icon-user","leaf"
//:true,"bindPanel":"newFetionCMS.ChannelGrid\(\{webserviceURL:URL\\)","expanded":false,"children":null
//}]}]}]


reader: new Ext.data.JsonReader({
root : 'ROOT'
},
[
{name : 'text', type: 'string'},
{name : 'cls', type: 'string'},
{name : 'iconCls', type: 'string'},
{name : 'bindPanel', type: 'Object'},
{name : 'leaf', type: 'bool'},
{name : 'expanded', type: 'bool'},
{name : 'children', type: 'Object'}
]
)
});
dataStore.load({
callback: function(r, options, success){
debugger
/*debugger on there the var r == 0:">*/
if (r.length > 0) {
node.beginUpdate();
debugger
for (var i = 0; i < r.length; i++) {
_THIS.appendSystemRole(node, r[i]);
}
node.endUpdate();
}
else {

}
}
});

if (typeof callback == "function") {
callback(this, node);
}
this.fireEvent("load", this, node, callback);
}
else {
if (typeof callback == "function") {
callback();
}
}
},


appendSystemRole : function(node, r) {
var ownerTree = node.getOwnerTree();
debugger
var newNode = this.createNode(r.text);
if (newNode) {
newNode.attributes.singleClickExpand = true;
newNode.attributes.cls = r.cls;
newNode.attributes.iconCls = r.iconCls;
newNode.attributes.bindPanel = r.bindPanel;
newNode.attributes.leaf = r.leaf;
newNode.attributes.expanded = r.expanded;
newNode.attributes.children = r.children;
newNode.attributes.checked = node.attributes.checked;

if (ownerTree) {
if (ownerTree.functionIDArray && ownerTree.functionIDArray.length > 0) {
for (var i = 0; i < ownerTree.functionIDArray.length; i++) {
if (newNode.attributes.functionID == ownerTree.functionIDArray[i]) {
newNode.attributes.checked = true;
}
}
}
}
node.appendChild(newNode);
}
}
});



extend Ext.tree.TreePanel
[CODE]
CMS.SystemTreeMenu = function(parentView, config) {
this.parentView = parentView;
Ext.apply(this, config);

this.functionIDArray = new Array();

CMS.SystemTreeMenu.superclass.constructor.call(this, {
region: 'west',
width: 180,
split: true,
miniSize: 100,
maxSize: 200,
margins: '0 0 0 0',
title: '

mdissel
17 Aug 2008, 2:05 AM
What are you trying to do? treepanel supports json loading out of the box (without a JsonReader), including extra properties for each node..

haoduotnt
17 Aug 2008, 2:27 AM
What are you trying to do? treepanel supports json loading out of the box (without a JsonReader), including extra properties for each node..

:"> i know treepanel supports json ,but i need do this
bindPanel : new CMS.ChannelGrid({webserviceURL:URL})

the channelGrid extend GridPanel ,onclick this treenode will create a new GridPanl on the east

use Ext.tree.TreeLoader({
dataUrl: .....
})

the bindPanel :"new CMS.ChannelGrid({webserviceURL:URL)" like a string value,not a object ,

:"> Sorry! My English is not fluent!