读书人

Ext2.2 Tree加载本土数据

发布时间: 2012-10-07 17:28:51 作者: rapoo

Ext2.2 Tree加载本地数据
Ext2.x的Tree不支持加载本地数据,项目需要自己重写源码.
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对象

读书人网 >Web前端

热点推荐