/ext-4.0.7/docs/source/TableChunker.html
HTML | 158 lines | 140 code | 18 blank | 0 comment | 0 complexity | 7f3b260a19101be773323887b50230ea MD5 | raw file
1<!DOCTYPE html>
2<html>
3<head>
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; }
10 </style>
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
14 }
15 </script>
16</head>
17<body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-view-TableChunker'>/**
19</span> * @class Ext.view.TableChunker
20 *
21 * Produces optimized XTemplates for chunks of tables to be
22 * used in grids, trees and other table based widgets.
23 *
24 * @singleton
25 */
26Ext.define('Ext.view.TableChunker', {
27 singleton: true,
28 requires: ['Ext.XTemplate'],
29 metaTableTpl: [
30 '{[this.openTableWrap()]}',
31 '<table class="' + Ext.baseCSSPrefix + 'grid-table ' + Ext.baseCSSPrefix + 'grid-table-resizer" border="0" cellspacing="0" cellpadding="0" {[this.embedFullWidth()]}>',
32 '<tbody>',
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>',
36 '</tpl>',
37 '</tr>',
38 '{[this.openRows()]}',
39 '{row}',
40 '<tpl for="features">',
41 '{[this.embedFeature(values, parent, xindex, xcount)]}',
42 '</tpl>',
43 '{[this.closeRows()]}',
44 '</tbody>',
45 '</table>',
46 '{[this.closeTableWrap()]}'
47 ],
48
49 constructor: function() {
50 Ext.XTemplate.prototype.recurse = function(values, reference) {
51 return this.apply(reference ? values[reference] : values);
52 };
53 },
54
55 embedFeature: function(values, parent, x, xcount) {
56 var tpl = '';
57 if (!values.disabled) {
58 tpl = values.getFeatureTpl(values, parent, x, xcount);
59 }
60 return tpl;
61 },
62
63 embedFullWidth: function() {
64 return 'style="width: {fullWidth}px;"';
65 },
66
67 openRows: function() {
68 return '<tpl for="rows">';
69 },
70
71 closeRows: function() {
72 return '</tpl>';
73 },
74
75 metaRowTpl: [
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>',
79 '</tpl>',
80 '</tr>'
81 ],
82
83 firstOrLastCls: function(xindex, xcount) {
84 var cssCls = '';
85 if (xindex === 1) {
86 cssCls = Ext.baseCSSPrefix + 'grid-cell-first';
87 } else if (xindex === xcount) {
88 cssCls = Ext.baseCSSPrefix + 'grid-cell-last';
89 }
90 return cssCls;
91 },
92
93 embedRowCls: function() {
94 return '{rowCls}';
95 },
96
97 embedRowAttr: function() {
98 return '{rowAttr}';
99 },
100
101 openTableWrap: function() {
102 return '';
103 },
104
105 closeTableWrap: function() {
106 return '';
107 },
108
109 getTableTpl: function(cfg, textOnly) {
110 var tpl,
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
118 },
119 tplMemberFns = {},
120 features = cfg.features || [],
121 ln = features.length,
122 i = 0,
123 memberFns = {
124 embedRowCls: this.embedRowCls,
125 embedRowAttr: this.embedRowAttr,
126 firstOrLastCls: this.firstOrLastCls
127 },
128 // copy the default
129 metaRowTpl = Array.prototype.slice.call(this.metaRowTpl, 0),
130 metaTableTpl;
131
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());
138 }
139 }
140
141 metaRowTpl = Ext.create('Ext.XTemplate', metaRowTpl.join(''), memberFns);
142 cfg.row = metaRowTpl.applyTemplate(cfg);
143
144 metaTableTpl = Ext.create('Ext.XTemplate', this.metaTableTpl.join(''), tableTplMemberFns);
145
146 tpl = metaTableTpl.applyTemplate(cfg);
147
148 // TODO: Investigate eliminating.
149 if (!textOnly) {
150 tpl = Ext.create('Ext.XTemplate', tpl, tplMemberFns);
151 }
152 return tpl;
153
154 }
155});
156</pre>
157</body>
158</html>