NavigationTreePanel.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. Ext.define('erp.view.common.main.NavigationTreePanel',{
  2. extend: 'Ext.tree.Panel',
  3. alias: 'widget.erpNavigationTreePanel',
  4. id: 'navigation-panel',
  5. margins : '0 0 -1 1',
  6. border : false,
  7. enableDD : false,
  8. split: true,
  9. title: $I18N.common.main.allNavigation,
  10. toggleCollapse: function() {
  11. if (this.collapsed) {
  12. this.expand(this.animCollapse);
  13. } else {
  14. this.title = $I18N.common.main.allNavigation,
  15. this.collapse(this.collapseDirection, this.animCollapse);
  16. }
  17. return this;
  18. },
  19. singleExpand: true,
  20. rootVisible: false,
  21. containerScroll : true,
  22. collapsible : true,
  23. autoScroll: false,
  24. useArrows: true,
  25. bodyStyle:'background-color:#f1f1f1;',
  26. store: Ext.create('Ext.data.TreeStore', {
  27. root : {
  28. text: 'root',
  29. id: 'root',
  30. expanded: true
  31. }}),
  32. hideHeaders: true,
  33. columnLines:false,
  34. initComponent : function(){
  35. var me=this;
  36. me.columns =[{
  37. xtype: 'treecolumn',
  38. dataIndex: 'text',
  39. flex: 0.9
  40. },{
  41. xtype: 'actioncolumn',
  42. flex: 0.1,
  43. //width: 24,
  44. tooltip: '查看说明',
  45. icon: (window.basePath || '') + 'resource/images/tree/add2.png',
  46. iconCls: 'x-hidden',
  47. renderer :function(val, meta, record){
  48. meta.tdCls = record.get('cls');
  49. //meta.tdAttr = record.get('leaf')?'data-qtip="新增'+record.get('text')+'"':'data-qtip="查看导航图"';
  50. },
  51. handler: Ext.bind(me.handleAddClick, me)
  52. }];
  53. this.getTreeRootNode(0);//页面加载时,只将parentId = 0的节点加载进来
  54. this.callParent(arguments);
  55. me.addEvents('addclick');
  56. },
  57. getTreeRootNode: function(parentId){
  58. var condition = this.baseCondition;
  59. Ext.Ajax.request({//拿到tree数据
  60. url : basePath + 'common/getAllNavigation.action',
  61. params: {
  62. parentId: parentId,
  63. condition: condition
  64. },
  65. callback : function(options,success,response){
  66. var res = new Ext.decode(response.responseText);
  67. if(res.tree){
  68. var tree = res.tree;
  69. Ext.getCmp('navigation-panel').store.setRootNode({
  70. text: 'root',
  71. id: 'root',
  72. expanded: true,
  73. children: tree
  74. });
  75. } else if(res.exceptionInfo){
  76. showError(res.exceptionInfo);
  77. }
  78. }
  79. });
  80. },
  81. tbar:{
  82. xtype: 'erpNavigationToolbar'
  83. },
  84. /*openCloseFun: function(){
  85. var o = Ext.getCmp("open");
  86. var c = Ext.getCmp("close");
  87. var tree = Ext.getCmp('tree-panel');
  88. if(o.hidden==false&&c.hidden==true){
  89. tree.expandAll();
  90. o.hide();
  91. c.show();
  92. }else{
  93. tree.collapseAll();
  94. o.show();
  95. c.hide();
  96. }
  97. },*/
  98. listeners: {//滚动条有时候没反应,添加此监听器
  99. scrollershow: function(scroller) {
  100. if (scroller && scroller.scrollEl) {
  101. scroller.clearManagedListeners();
  102. scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
  103. }
  104. }
  105. },
  106. handleAddClick: function(gridView, rowIndex, colIndex, column, e) {
  107. this.fireEvent('addclick', gridView, rowIndex, colIndex, column, e);
  108. }
  109. });