source: trunk/web/addons/job_monarch/lib/extjs/examples/tree/ColumnNodeUI.js @ 619

Last change on this file since 619 was 619, checked in by ramonb, 15 years ago

lib/:

  • added new AJAX dependancies: ExtJS, pChart, Lightbox2
File size: 3.7 KB
Line 
1/*
2 * Ext JS Library 2.2.1
3 * Copyright(c) 2006-2009, Ext JS, LLC.
4 * licensing@extjs.com
5 *
6 * http://extjs.com/license
7 */
8
9Ext.tree.ColumnTree = Ext.extend(Ext.tree.TreePanel, {
10    lines:false,
11    borderWidth: Ext.isBorderBox ? 0 : 2, // the combined left/right border for each cell
12    cls:'x-column-tree',
13   
14    onRender : function(){
15        Ext.tree.ColumnTree.superclass.onRender.apply(this, arguments);
16        this.headers = this.body.createChild(
17            {cls:'x-tree-headers'},this.innerCt.dom);
18
19        var cols = this.columns, c;
20        var totalWidth = 0;
21
22        for(var i = 0, len = cols.length; i < len; i++){
23             c = cols[i];
24             totalWidth += c.width;
25             this.headers.createChild({
26                 cls:'x-tree-hd ' + (c.cls?c.cls+'-hd':''),
27                 cn: {
28                     cls:'x-tree-hd-text',
29                     html: c.header
30                 },
31                 style:'width:'+(c.width-this.borderWidth)+'px;'
32             });
33        }
34        this.headers.createChild({cls:'x-clear'});
35        // prevent floats from wrapping when clipped
36        this.headers.setWidth(totalWidth);
37        this.innerCt.setWidth(totalWidth);
38    }
39});
40
41Ext.tree.ColumnNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
42    focus: Ext.emptyFn, // prevent odd scrolling behavior
43
44    renderElements : function(n, a, targetNode, bulkRender){
45        this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
46
47        var t = n.getOwnerTree();
48        var cols = t.columns;
49        var bw = t.borderWidth;
50        var c = cols[0];
51
52        var buf = [
53             '<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf ', a.cls,'">',
54                '<div class="x-tree-col" style="width:',c.width-bw,'px;">',
55                    '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
56                    '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow">',
57                    '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on">',
58                    '<a hidefocus="on" class="x-tree-node-anchor" href="',a.href ? a.href : "#",'" tabIndex="1" ',
59                    a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '>',
60                    '<span unselectable="on">', n.text || (c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</span></a>",
61                "</div>"];
62         for(var i = 1, len = cols.length; i < len; i++){
63             c = cols[i];
64
65             buf.push('<div class="x-tree-col ',(c.cls?c.cls:''),'" style="width:',c.width-bw,'px;">',
66                        '<div class="x-tree-col-text">',(c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</div>",
67                      "</div>");
68         }
69         buf.push(
70            '<div class="x-clear"></div></div>',
71            '<ul class="x-tree-node-ct" style="display:none;"></ul>',
72            "</li>");
73
74        if(bulkRender !== true && n.nextSibling && n.nextSibling.ui.getEl()){
75            this.wrap = Ext.DomHelper.insertHtml("beforeBegin",
76                                n.nextSibling.ui.getEl(), buf.join(""));
77        }else{
78            this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf.join(""));
79        }
80
81        this.elNode = this.wrap.childNodes[0];
82        this.ctNode = this.wrap.childNodes[1];
83        var cs = this.elNode.firstChild.childNodes;
84        this.indentNode = cs[0];
85        this.ecNode = cs[1];
86        this.iconNode = cs[2];
87        this.anchor = cs[3];
88        this.textNode = cs[3].firstChild;
89    }
90});
Note: See TracBrowser for help on using the repository browser.