3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * @class Ext.tree.Column
17 * @extends Ext.grid.column.Column
19 * Provides indentation and folder structure markup for a Tree taking into account
20 * depth and position within the tree hierarchy.
24 Ext.define('Ext.tree.Column', {
25 extend: 'Ext.grid.column.Column',
26 alias: 'widget.treecolumn',
28 initComponent: function() {
29 var origRenderer = this.renderer || this.defaultRenderer,
30 origScope = this.scope || window;
32 this.renderer = function(value, metaData, record, rowIdx, colIdx, store, view) {
34 format = Ext.String.format,
35 depth = record.getDepth(),
36 treePrefix = Ext.baseCSSPrefix + 'tree-',
37 elbowPrefix = treePrefix + 'elbow-',
38 expanderCls = treePrefix + 'expander',
39 imgText = '<img src="{1}" class="{0}" />',
40 checkboxText= '<input type="button" role="checkbox" class="{0}" {1} />',
41 formattedValue = origRenderer.apply(origScope, arguments),
42 href = record.get('href'),
43 target = record.get('hrefTarget'),
44 cls = record.get('cls');
47 if (!record.isRoot() || (record.isRoot() && view.rootVisible)) {
48 if (record.getDepth() === depth) {
49 buf.unshift(format(imgText,
50 treePrefix + 'icon ' +
51 treePrefix + 'icon' + (record.get('icon') ? '-inline ' : (record.isLeaf() ? '-leaf ' : '-parent ')) +
52 (record.get('iconCls') || ''),
53 record.get('icon') || Ext.BLANK_IMAGE_URL
55 if (record.get('checked') !== null) {
58 (treePrefix + 'checkbox') + (record.get('checked') ? ' ' + treePrefix + 'checkbox-checked' : ''),
59 record.get('checked') ? 'aria-checked="true"' : ''
61 if (record.get('checked')) {
62 metaData.tdCls += (' ' + treePrefix + 'checked');
65 if (record.isLast()) {
66 if (record.isExpandable()) {
67 buf.unshift(format(imgText, (elbowPrefix + 'end-plus ' + expanderCls), Ext.BLANK_IMAGE_URL));
69 buf.unshift(format(imgText, (elbowPrefix + 'end'), Ext.BLANK_IMAGE_URL));
73 if (record.isExpandable()) {
74 buf.unshift(format(imgText, (elbowPrefix + 'plus ' + expanderCls), Ext.BLANK_IMAGE_URL));
76 buf.unshift(format(imgText, (treePrefix + 'elbow'), Ext.BLANK_IMAGE_URL));
80 if (record.isLast() || record.getDepth() === 0) {
81 buf.unshift(format(imgText, (elbowPrefix + 'empty'), Ext.BLANK_IMAGE_URL));
82 } else if (record.getDepth() !== 0) {
83 buf.unshift(format(imgText, (elbowPrefix + 'line'), Ext.BLANK_IMAGE_URL));
87 record = record.parentNode;
90 buf.push('<a href="', href, '" target="', target, '">', formattedValue, '</a>');
92 buf.push(formattedValue);
95 metaData.tdCls += ' ' + cls;
99 this.callParent(arguments);
102 defaultRenderer: function(value) {