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.

120 lines
4.5 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. /**
  16. * @class Ext.ux.tree.TreeGridNodeUI
  17. * @extends Ext.tree.TreeNodeUI
  18. */
  19. Ext.ux.tree.TreeGridNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
  20. isTreeGridNodeUI: true,
  21. renderElements : function(n, a, targetNode, bulkRender){
  22. var t = n.getOwnerTree(),
  23. cols = t.columns,
  24. c = cols[0],
  25. i, buf, len;
  26. this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
  27. buf = [
  28. '<tbody class="x-tree-node">',
  29. '<tr ext:tree-node-id="', n.id ,'" class="x-tree-node-el x-tree-node-leaf ', a.cls, '">',
  30. '<td class="x-treegrid-col">',
  31. '<span class="x-tree-node-indent">', this.indentMarkup, "</span>",
  32. '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow" />',
  33. '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon', (a.icon ? " x-tree-node-inline-icon" : ""), (a.iconCls ? " "+a.iconCls : ""), '" unselectable="on" />',
  34. '<a hidefocus="on" class="x-tree-node-anchor" href="', a.href ? a.href : '#', '" tabIndex="1" ',
  35. a.hrefTarget ? ' target="'+a.hrefTarget+'"' : '', '>',
  36. '<span unselectable="on">', (c.tpl ? c.tpl.apply(a) : a[c.dataIndex] || c.text), '</span></a>',
  37. '</td>'
  38. ];
  39. for(i = 1, len = cols.length; i < len; i++){
  40. c = cols[i];
  41. buf.push(
  42. '<td class="x-treegrid-col ', (c.cls ? c.cls : ''), '">',
  43. '<div unselectable="on" class="x-treegrid-text"', (c.align ? ' style="text-align: ' + c.align + ';"' : ''), '>',
  44. (c.tpl ? c.tpl.apply(a) : a[c.dataIndex]),
  45. '</div>',
  46. '</td>'
  47. );
  48. }
  49. buf.push(
  50. '</tr><tr class="x-tree-node-ct"><td colspan="', cols.length, '">',
  51. '<table class="x-treegrid-node-ct-table" cellpadding="0" cellspacing="0" style="table-layout: fixed; display: none; width: ', t.innerCt.getWidth() ,'px;"><colgroup>'
  52. );
  53. for(i = 0, len = cols.length; i<len; i++) {
  54. buf.push('<col style="width: ', (cols[i].hidden ? 0 : cols[i].width) ,'px;" />');
  55. }
  56. buf.push('</colgroup></table></td></tr></tbody>');
  57. if(bulkRender !== true && n.nextSibling && n.nextSibling.ui.getEl()){
  58. this.wrap = Ext.DomHelper.insertHtml("beforeBegin", n.nextSibling.ui.getEl(), buf.join(''));
  59. }else{
  60. this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf.join(''));
  61. }
  62. this.elNode = this.wrap.childNodes[0];
  63. this.ctNode = this.wrap.childNodes[1].firstChild.firstChild;
  64. var cs = this.elNode.firstChild.childNodes;
  65. this.indentNode = cs[0];
  66. this.ecNode = cs[1];
  67. this.iconNode = cs[2];
  68. this.anchor = cs[3];
  69. this.textNode = cs[3].firstChild;
  70. },
  71. // private
  72. animExpand : function(cb){
  73. this.ctNode.style.display = "";
  74. Ext.ux.tree.TreeGridNodeUI.superclass.animExpand.call(this, cb);
  75. }
  76. });
  77. Ext.ux.tree.TreeGridRootNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
  78. isTreeGridNodeUI: true,
  79. // private
  80. render : function(){
  81. if(!this.rendered){
  82. this.wrap = this.ctNode = this.node.ownerTree.innerCt.dom;
  83. this.node.expanded = true;
  84. }
  85. if(Ext.isWebKit) {
  86. // weird table-layout: fixed issue in webkit
  87. var ct = this.ctNode;
  88. ct.style.tableLayout = null;
  89. (function() {
  90. ct.style.tableLayout = 'fixed';
  91. }).defer(1);
  92. }
  93. },
  94. destroy : function(){
  95. if(this.elNode){
  96. Ext.dd.Registry.unregister(this.elNode.id);
  97. }
  98. delete this.node;
  99. },
  100. collapse : Ext.emptyFn,
  101. expand : Ext.emptyFn
  102. });