Ext.define('erp.view.common.main.TreePanel',{ extend: 'Ext.tree.Panel', alias: 'widget.erpTreePanel', id: 'tree-panel', /*region: 'west',*/ /*width : '20%',*/ margins : '0 0 -1 1', border : false, enableDD : false, split: true, title: $I18N.common.main.navigation, toggleCollapse: function() { if (this.collapsed) { this.expand(this.animCollapse); } else { this.title = $I18N.common.main.navigation; this.collapse(this.collapseDirection, this.animCollapse); } return this; }, singleExpand: true, rootVisible: false, containerScroll : true, collapsible : true, autoScroll: false, useArrows: true, bodyStyle:'background-color:#f1f1f1;', store:'TreeStore', initComponent : function(){ this.getTreeRootNode(0);//页面加载时,只将parentId = 0的节点加载进来 this.callParent(arguments); }, getTreeRootNode: function(parentId){ var condition = this.baseCondition; Ext.Ajax.request({//拿到tree数据 url : basePath + 'common/lazyTree.action', params: { parentId: parentId, condition: condition }, callback : function(options,success,response){ var res = new Ext.decode(response.responseText); if(res.tree){ var tree = res.tree; Ext.getCmp('tree-panel').store.setRootNode({ text: 'root', id: 'root', expanded: true, children: tree }); } else if(res.exceptionInfo){ showError(res.exceptionInfo); } } }); }, tbar:{ xtype: 'erpTreeToolbar' }, openCloseFun: function(){ var o = Ext.getCmp("open"); var c = Ext.getCmp("close"); var tree = Ext.getCmp('tree-panel'); if(o.hidden==false&&c.hidden==true){ tree.expandAll(); o.hide(); c.show(); }else{ tree.collapseAll(); o.show(); c.hide(); } }, listeners: {//滚动条有时候没反应,添加此监听器 scrollershow: function(scroller) { if (scroller && scroller.scrollEl) { scroller.clearManagedListeners(); scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller); } } } });