Ext.define('erp.view.common.main.NavigationTreePanel',{ extend: 'Ext.tree.Panel', alias: 'widget.erpNavigationTreePanel', id: 'navigation-panel', margins : '0 0 -1 1', border : false, enableDD : false, split: true, title: $I18N.common.main.allNavigation, toggleCollapse: function() { if (this.collapsed) { this.expand(this.animCollapse); } else { this.title = $I18N.common.main.allNavigation, 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: Ext.create('Ext.data.TreeStore', { root : { text: 'root', id: 'root', expanded: true }}), hideHeaders: true, columnLines:false, initComponent : function(){ var me=this; me.columns =[{ xtype: 'treecolumn', dataIndex: 'text', flex: 0.9 },{ xtype: 'actioncolumn', flex: 0.1, //width: 24, tooltip: '查看说明', icon: (window.basePath || '') + 'resource/images/tree/add2.png', iconCls: 'x-hidden', renderer :function(val, meta, record){ meta.tdCls = record.get('cls'); //meta.tdAttr = record.get('leaf')?'data-qtip="新增'+record.get('text')+'"':'data-qtip="查看导航图"'; }, handler: Ext.bind(me.handleAddClick, me) }]; this.getTreeRootNode(0);//页面加载时,只将parentId = 0的节点加载进来 this.callParent(arguments); me.addEvents('addclick'); }, getTreeRootNode: function(parentId){ var condition = this.baseCondition; Ext.Ajax.request({//拿到tree数据 url : basePath + 'common/getAllNavigation.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('navigation-panel').store.setRootNode({ text: 'root', id: 'root', expanded: true, children: tree }); } else if(res.exceptionInfo){ showError(res.exceptionInfo); } } }); }, tbar:{ xtype: 'erpNavigationToolbar' }, /*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); } } }, handleAddClick: function(gridView, rowIndex, colIndex, column, e) { this.fireEvent('addclick', gridView, rowIndex, colIndex, column, e); } });