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.view.TableChunker
18 * Produces optimized XTemplates for chunks of tables to be
19 * used in grids, trees and other table based widgets.
23 Ext.define('Ext.view.TableChunker', {
25 requires: ['Ext.XTemplate'],
27 '{[this.openTableWrap()]}',
28 '<table class="' + Ext.baseCSSPrefix + 'grid-table ' + Ext.baseCSSPrefix + 'grid-table-resizer" border="0" cellspacing="0" cellpadding="0" {[this.embedFullWidth()]}>',
30 '<tr class="' + Ext.baseCSSPrefix + 'grid-header-row">',
31 '<tpl for="columns">',
32 '<th class="' + Ext.baseCSSPrefix + 'grid-col-resizer-{id}" style="width: {width}px; height: 0px;"></th>',
35 '{[this.openRows()]}',
37 '<tpl for="features">',
38 '{[this.embedFeature(values, parent, xindex, xcount)]}',
40 '{[this.closeRows()]}',
43 '{[this.closeTableWrap()]}'
46 constructor: function() {
47 Ext.XTemplate.prototype.recurse = function(values, reference) {
48 return this.apply(reference ? values[reference] : values);
52 embedFeature: function(values, parent, x, xcount) {
54 if (!values.disabled) {
55 tpl = values.getFeatureTpl(values, parent, x, xcount);
60 embedFullWidth: function() {
61 return 'style="width: {fullWidth}px;"';
64 openRows: function() {
65 return '<tpl for="rows">';
68 closeRows: function() {
73 '<tr class="' + Ext.baseCSSPrefix + 'grid-row {addlSelector} {[this.embedRowCls()]}" {[this.embedRowAttr()]}>',
74 '<tpl for="columns">',
75 '<td class="{cls} ' + Ext.baseCSSPrefix + 'grid-cell ' + Ext.baseCSSPrefix + 'grid-cell-{columnId} {{id}-modified} {{id}-tdCls} {[this.firstOrLastCls(xindex, xcount)]}" {{id}-tdAttr}><div unselectable="on" class="' + Ext.baseCSSPrefix + 'grid-cell-inner ' + Ext.baseCSSPrefix + 'unselectable" style="{{id}-style}; text-align: {align};">{{id}}</div></td>',
80 firstOrLastCls: function(xindex, xcount) {
83 cssCls = Ext.baseCSSPrefix + 'grid-cell-first';
84 } else if (xindex === xcount) {
85 cssCls = Ext.baseCSSPrefix + 'grid-cell-last';
90 embedRowCls: function() {
94 embedRowAttr: function() {
98 openTableWrap: function() {
102 closeTableWrap: function() {
106 getTableTpl: function(cfg, textOnly) {
108 tableTplMemberFns = {
109 openRows: this.openRows,
110 closeRows: this.closeRows,
111 embedFeature: this.embedFeature,
112 embedFullWidth: this.embedFullWidth,
113 openTableWrap: this.openTableWrap,
114 closeTableWrap: this.closeTableWrap
117 features = cfg.features || [],
118 ln = features.length,
121 embedRowCls: this.embedRowCls,
122 embedRowAttr: this.embedRowAttr,
123 firstOrLastCls: this.firstOrLastCls
126 metaRowTpl = Array.prototype.slice.call(this.metaRowTpl, 0),
129 for (; i < ln; i++) {
130 if (!features[i].disabled) {
131 features[i].mutateMetaRowTpl(metaRowTpl);
132 Ext.apply(memberFns, features[i].getMetaRowTplFragments());
133 Ext.apply(tplMemberFns, features[i].getFragmentTpl());
134 Ext.apply(tableTplMemberFns, features[i].getTableFragments());
138 metaRowTpl = Ext.create('Ext.XTemplate', metaRowTpl.join(''), memberFns);
139 cfg.row = metaRowTpl.applyTemplate(cfg);
141 metaTableTpl = Ext.create('Ext.XTemplate', this.metaTableTpl.join(''), tableTplMemberFns);
143 tpl = metaTableTpl.applyTemplate(cfg);
145 // TODO: Investigate eliminating.
147 tpl = Ext.create('Ext.XTemplate', tpl, tplMemberFns);