4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-view-TableChunker'>/**
19 </span> * @class Ext.view.TableChunker
21 * Produces optimized XTemplates for chunks of tables to be
22 * used in grids, trees and other table based widgets.
26 Ext.define('Ext.view.TableChunker', {
28 requires: ['Ext.XTemplate'],
30 '{[this.openTableWrap()]}',
31 '<table class="' + Ext.baseCSSPrefix + 'grid-table ' + Ext.baseCSSPrefix + 'grid-table-resizer" border="0" cellspacing="0" cellpadding="0" {[this.embedFullWidth()]}>',
33 '<tr class="' + Ext.baseCSSPrefix + 'grid-header-row">',
34 '<tpl for="columns">',
35 '<th class="' + Ext.baseCSSPrefix + 'grid-col-resizer-{id}" style="width: {width}px; height: 0px;"></th>',
38 '{[this.openRows()]}',
40 '<tpl for="features">',
41 '{[this.embedFeature(values, parent, xindex, xcount)]}',
43 '{[this.closeRows()]}',
46 '{[this.closeTableWrap()]}'
49 constructor: function() {
50 Ext.XTemplate.prototype.recurse = function(values, reference) {
51 return this.apply(reference ? values[reference] : values);
55 embedFeature: function(values, parent, x, xcount) {
57 if (!values.disabled) {
58 tpl = values.getFeatureTpl(values, parent, x, xcount);
63 embedFullWidth: function() {
64 return 'style="width: {fullWidth}px;"';
67 openRows: function() {
68 return '<tpl for="rows">';
71 closeRows: function() {
72 return '</tpl>';
76 '<tr class="' + Ext.baseCSSPrefix + 'grid-row {addlSelector} {[this.embedRowCls()]}" {[this.embedRowAttr()]}>',
77 '<tpl for="columns">',
78 '<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>',
83 firstOrLastCls: function(xindex, xcount) {
86 cssCls = Ext.baseCSSPrefix + 'grid-cell-first';
87 } else if (xindex === xcount) {
88 cssCls = Ext.baseCSSPrefix + 'grid-cell-last';
93 embedRowCls: function() {
97 embedRowAttr: function() {
101 openTableWrap: function() {
105 closeTableWrap: function() {
109 getTableTpl: function(cfg, textOnly) {
111 tableTplMemberFns = {
112 openRows: this.openRows,
113 closeRows: this.closeRows,
114 embedFeature: this.embedFeature,
115 embedFullWidth: this.embedFullWidth,
116 openTableWrap: this.openTableWrap,
117 closeTableWrap: this.closeTableWrap
120 features = cfg.features || [],
121 ln = features.length,
124 embedRowCls: this.embedRowCls,
125 embedRowAttr: this.embedRowAttr,
126 firstOrLastCls: this.firstOrLastCls
129 metaRowTpl = Array.prototype.slice.call(this.metaRowTpl, 0),
132 for (; i < ln; i++) {
133 if (!features[i].disabled) {
134 features[i].mutateMetaRowTpl(metaRowTpl);
135 Ext.apply(memberFns, features[i].getMetaRowTplFragments());
136 Ext.apply(tplMemberFns, features[i].getFragmentTpl());
137 Ext.apply(tableTplMemberFns, features[i].getTableFragments());
141 metaRowTpl = Ext.create('Ext.XTemplate', metaRowTpl.join(''), memberFns);
142 cfg.row = metaRowTpl.applyTemplate(cfg);
144 metaTableTpl = Ext.create('Ext.XTemplate', this.metaTableTpl.join(''), tableTplMemberFns);
146 tpl = metaTableTpl.applyTemplate(cfg);
148 // TODO: Investigate eliminating.
150 tpl = Ext.create('Ext.XTemplate', tpl, tplMemberFns);