快捷搜索:

Extjs4.x Ext.tree.Panel实现遍历当前节点下的所有子节

Ext.define('WMS.controller.Org', {

extend: 'Ext.app.Controller',stores: ['OrgUser', 'OrgTree'],

models: ['OrgUser'],views: ['OrgTb', 'OrgTree', 'OrgUserGrid'],

refs: [{

ref: 'orgTree',selector: 'orgTree'

},{

ref: 'OrgUserGrid',selector: 'OrgUserGrid'

}],

init: function () {this.control({

'OrgTree': {itemclick: function (view, record, item, index) {

var id = record.getId();var Enode = view.getTreeStore().getNodeById(id);

var idArray = new Array();//遍历树,放到array里idArray.push(id);

if (id != "0")this.GetChilds(idArray, Enode);

usrstore = this.getOrgUserStore();usrstore.getProxy().setExtraParam("ids", idArray);

usrstore.load();}

});

},//递归

GetChilds: function (idArray,node) {ts = this;

childnodes = node.childNodes;Ext.each(childnodes,function () {

var nd = this;idArray.push(nd.getId());

if (nd.hasChildNodes()) {ts.GetChilds(idArray, nd);

}});

}});

您可能还会对下面的文章感兴趣: