Upgrade to ExtJS 3.3.1 - Released 11/30/2010
[extjs.git] / examples / docs / source / TreeGridNodeUI.html
1 <html>
2 <head>
3   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
4   <title>The source code</title>
5     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 </head>
8 <body  onload="prettyPrint();">
9     <pre class="prettyprint lang-js">/*!
10  * Ext JS Library 3.3.1
11  * Copyright(c) 2006-2010 Sencha Inc.
12  * licensing@sencha.com
13  * http://www.sencha.com/license
14  */
15 <div id="cls-Ext.ux.tree.TreeGridNodeUI"></div>/**
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
22     renderElements : function(n, a, targetNode, bulkRender){
23         var t = n.getOwnerTree(),
24             cols = t.columns,
25             c = cols[0],
26             i, buf, len;
27
28         this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
29
30         buf = [
31              '<tbody class="x-tree-node">',
32                 '<tr ext:tree-node-id="', n.id ,'" class="x-tree-node-el x-tree-node-leaf ', a.cls, '">',
33                     '<td class="x-treegrid-col">',
34                         '<span class="x-tree-node-indent">', this.indentMarkup, "</span>",
35                         '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow" />',
36                         '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon', (a.icon ? " x-tree-node-inline-icon" : ""), (a.iconCls ? " "+a.iconCls : ""), '" unselectable="on" />',
37                         '<a hidefocus="on" class="x-tree-node-anchor" href="', a.href ? a.href : '#', '" tabIndex="1" ',
38                             a.hrefTarget ? ' target="'+a.hrefTarget+'"' : '', '>',
39                         '<span unselectable="on">', (c.tpl ? c.tpl.apply(a) : a[c.dataIndex] || c.text), '</span></a>',
40                     '</td>'
41         ];
42
43         for(i = 1, len = cols.length; i < len; i++){
44             c = cols[i];
45             buf.push(
46                     '<td class="x-treegrid-col ', (c.cls ? c.cls : ''), '">',
47                         '<div unselectable="on" class="x-treegrid-text"', (c.align ? ' style="text-align: ' + c.align + ';"' : ''), '>',
48                             (c.tpl ? c.tpl.apply(a) : a[c.dataIndex]),
49                         '</div>',
50                     '</td>'
51             );
52         }
53
54         buf.push(
55             '</tr><tr class="x-tree-node-ct"><td colspan="', cols.length, '">',
56             '<table class="x-treegrid-node-ct-table" cellpadding="0" cellspacing="0" style="table-layout: fixed; display: none; width: ', t.innerCt.getWidth() ,'px;"><colgroup>'
57         );
58         for(i = 0, len = cols.length; i<len; i++) {
59             buf.push('<col style="width: ', (cols[i].hidden ? 0 : cols[i].width) ,'px;" />');
60         }
61         buf.push('</colgroup></table></td></tr></tbody>');
62
63         if(bulkRender !== true && n.nextSibling && n.nextSibling.ui.getEl()){
64             this.wrap = Ext.DomHelper.insertHtml("beforeBegin", n.nextSibling.ui.getEl(), buf.join(''));
65         }else{
66             this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf.join(''));
67         }
68
69         this.elNode = this.wrap.childNodes[0];
70         this.ctNode = this.wrap.childNodes[1].firstChild.firstChild;
71         var cs = this.elNode.firstChild.childNodes;
72         this.indentNode = cs[0];
73         this.ecNode = cs[1];
74         this.iconNode = cs[2];
75         this.anchor = cs[3];
76         this.textNode = cs[3].firstChild;
77     },
78
79     // private
80     animExpand : function(cb){
81         this.ctNode.style.display = "";
82         Ext.ux.tree.TreeGridNodeUI.superclass.animExpand.call(this, cb);
83     }
84 });
85
86 Ext.ux.tree.TreeGridRootNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
87     isTreeGridNodeUI: true,
88
89     // private
90     render : function(){
91         if(!this.rendered){
92             this.wrap = this.ctNode = this.node.ownerTree.innerCt.dom;
93             this.node.expanded = true;
94         }
95
96         if(Ext.isWebKit) {
97             // weird table-layout: fixed issue in webkit
98             var ct = this.ctNode;
99             ct.style.tableLayout = null;
100             (function() {
101                 ct.style.tableLayout = 'fixed';
102             }).defer(1);
103         }
104     },
105
106     destroy : function(){
107         if(this.elNode){
108             Ext.dd.Registry.unregister(this.elNode.id);
109         }
110         delete this.node;
111     },
112
113     collapse : Ext.emptyFn,
114     expand : Ext.emptyFn
115 });</pre>    
116 </body>
117 </html>