You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
4.6 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. Ext.ns('Ext.ux.tree');
  16. /**
  17. * @class Ext.ux.tree.ColumnTree
  18. * @extends Ext.tree.TreePanel
  19. *
  20. * @xtype columntree
  21. */
  22. Ext.ux.tree.ColumnTree = Ext.extend(Ext.tree.TreePanel, {
  23. lines : false,
  24. borderWidth : Ext.isBorderBox ? 0 : 2, // the combined left/right border for each cell
  25. cls : 'x-column-tree',
  26. onRender : function(){
  27. Ext.tree.ColumnTree.superclass.onRender.apply(this, arguments);
  28. this.headers = this.header.createChild({cls:'x-tree-headers'});
  29. var cols = this.columns, c;
  30. var totalWidth = 0;
  31. var scrollOffset = 19; // similar to Ext.grid.GridView default
  32. for(var i = 0, len = cols.length; i < len; i++){
  33. c = cols[i];
  34. totalWidth += c.width;
  35. this.headers.createChild({
  36. cls:'x-tree-hd ' + (c.cls?c.cls+'-hd':''),
  37. cn: {
  38. cls:'x-tree-hd-text',
  39. html: c.header
  40. },
  41. style:'width:'+(c.width-this.borderWidth)+'px;'
  42. });
  43. }
  44. this.headers.createChild({cls:'x-clear'});
  45. // prevent floats from wrapping when clipped
  46. this.headers.setWidth(totalWidth+scrollOffset);
  47. this.innerCt.setWidth(totalWidth);
  48. }
  49. });
  50. Ext.reg('columntree', Ext.ux.tree.ColumnTree);
  51. //backwards compat
  52. Ext.tree.ColumnTree = Ext.ux.tree.ColumnTree;
  53. /**
  54. * @class Ext.ux.tree.ColumnNodeUI
  55. * @extends Ext.tree.TreeNodeUI
  56. */
  57. Ext.ux.tree.ColumnNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
  58. focus: Ext.emptyFn, // prevent odd scrolling behavior
  59. renderElements : function(n, a, targetNode, bulkRender){
  60. this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
  61. var t = n.getOwnerTree();
  62. var cols = t.columns;
  63. var bw = t.borderWidth;
  64. var c = cols[0];
  65. var buf = [
  66. '<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf ', a.cls,'">',
  67. '<div class="x-tree-col" style="width:',c.width-bw,'px;">',
  68. '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
  69. '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow">',
  70. '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on">',
  71. '<a hidefocus="on" class="x-tree-node-anchor" href="',a.href ? a.href : "#",'" tabIndex="1" ',
  72. a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '>',
  73. '<span unselectable="on">', n.text || (c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</span></a>",
  74. "</div>"];
  75. for(var i = 1, len = cols.length; i < len; i++){
  76. c = cols[i];
  77. buf.push('<div class="x-tree-col ',(c.cls?c.cls:''),'" style="width:',c.width-bw,'px;">',
  78. '<div class="x-tree-col-text">',(c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</div>",
  79. "</div>");
  80. }
  81. buf.push(
  82. '<div class="x-clear"></div></div>',
  83. '<ul class="x-tree-node-ct" style="display:none;"></ul>',
  84. "</li>");
  85. if(bulkRender !== true && n.nextSibling && n.nextSibling.ui.getEl()){
  86. this.wrap = Ext.DomHelper.insertHtml("beforeBegin",
  87. n.nextSibling.ui.getEl(), buf.join(""));
  88. }else{
  89. this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf.join(""));
  90. }
  91. this.elNode = this.wrap.childNodes[0];
  92. this.ctNode = this.wrap.childNodes[1];
  93. var cs = this.elNode.firstChild.childNodes;
  94. this.indentNode = cs[0];
  95. this.ecNode = cs[1];
  96. this.iconNode = cs[2];
  97. this.anchor = cs[3];
  98. this.textNode = cs[3].firstChild;
  99. }
  100. });
  101. //backwards compat
  102. Ext.tree.ColumnNodeUI = Ext.ux.tree.ColumnNodeUI;