Ext2.x的Tree不支持加载本地数据,项目需要自己重写源码.
TreeLoader源码的load方法添加:
然后主要处理方法handleLocalData:
然后构造treeloader的时候使用localData参数构造,该参数接受一个具有treeNode属性的json对象
TreeLoader源码的load方法添加:
load : function(node, callback){
if(this.localData){
this.handleLocalData(node,callback);
return;
}
....
然后主要处理方法handleLocalData:
//handle local data
handleLocalData:function(node, callback){
if(this.doPreload(node)){
if(typeof callback == "function"){
callback();
}
return;
}
if (this.clearOnLoad) {
while (node.firstChild) {
node.removeChild(node.firstChild);
}
}
this.transId = false;
//copy a data from source
try {
var o = this.localData;
node.beginUpdate();
for(var i = 0, len = o.length; i < len; i++){
var n = this.createNode(o[i]);
if(n){
node.appendChild(n);
}
}
node.endUpdate();
if(typeof callback == "function"){
callback(this, node);
}
}catch(e){
}
this.fireEvent("load", this, node, this.localData);
}
然后构造treeloader的时候使用localData参数构造,该参数接受一个具有treeNode属性的json对象