/ext-4.0.7/docs/source/TableChunker.html

https://bitbucket.org/srogerf/javascript · 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. */
  26. Ext.define('Ext.view.TableChunker', {
  27. singleton: true,
  28. requires: ['Ext.XTemplate'],
  29. metaTableTpl: [
  30. '{[this.openTableWrap()]}',
  31. '&lt;table class=&quot;' + Ext.baseCSSPrefix + 'grid-table ' + Ext.baseCSSPrefix + 'grid-table-resizer&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; {[this.embedFullWidth()]}&gt;',
  32. '&lt;tbody&gt;',
  33. '&lt;tr class=&quot;' + Ext.baseCSSPrefix + 'grid-header-row&quot;&gt;',
  34. '&lt;tpl for=&quot;columns&quot;&gt;',
  35. '&lt;th class=&quot;' + Ext.baseCSSPrefix + 'grid-col-resizer-{id}&quot; style=&quot;width: {width}px; height: 0px;&quot;&gt;&lt;/th&gt;',
  36. '&lt;/tpl&gt;',
  37. '&lt;/tr&gt;',
  38. '{[this.openRows()]}',
  39. '{row}',
  40. '&lt;tpl for=&quot;features&quot;&gt;',
  41. '{[this.embedFeature(values, parent, xindex, xcount)]}',
  42. '&lt;/tpl&gt;',
  43. '{[this.closeRows()]}',
  44. '&lt;/tbody&gt;',
  45. '&lt;/table&gt;',
  46. '{[this.closeTableWrap()]}'
  47. ],
  48. constructor: function() {
  49. Ext.XTemplate.prototype.recurse = function(values, reference) {
  50. return this.apply(reference ? values[reference] : values);
  51. };
  52. },
  53. embedFeature: function(values, parent, x, xcount) {
  54. var tpl = '';
  55. if (!values.disabled) {
  56. tpl = values.getFeatureTpl(values, parent, x, xcount);
  57. }
  58. return tpl;
  59. },
  60. embedFullWidth: function() {
  61. return 'style=&quot;width: {fullWidth}px;&quot;';
  62. },
  63. openRows: function() {
  64. return '&lt;tpl for=&quot;rows&quot;&gt;';
  65. },
  66. closeRows: function() {
  67. return '&lt;/tpl&gt;';
  68. },
  69. metaRowTpl: [
  70. '&lt;tr class=&quot;' + Ext.baseCSSPrefix + 'grid-row {addlSelector} {[this.embedRowCls()]}&quot; {[this.embedRowAttr()]}&gt;',
  71. '&lt;tpl for=&quot;columns&quot;&gt;',
  72. '&lt;td class=&quot;{cls} ' + Ext.baseCSSPrefix + 'grid-cell ' + Ext.baseCSSPrefix + 'grid-cell-{columnId} {{id}-modified} {{id}-tdCls} {[this.firstOrLastCls(xindex, xcount)]}&quot; {{id}-tdAttr}&gt;&lt;div unselectable=&quot;on&quot; class=&quot;' + Ext.baseCSSPrefix + 'grid-cell-inner ' + Ext.baseCSSPrefix + 'unselectable&quot; style=&quot;{{id}-style}; text-align: {align};&quot;&gt;{{id}}&lt;/div&gt;&lt;/td&gt;',
  73. '&lt;/tpl&gt;',
  74. '&lt;/tr&gt;'
  75. ],
  76. firstOrLastCls: function(xindex, xcount) {
  77. var cssCls = '';
  78. if (xindex === 1) {
  79. cssCls = Ext.baseCSSPrefix + 'grid-cell-first';
  80. } else if (xindex === xcount) {
  81. cssCls = Ext.baseCSSPrefix + 'grid-cell-last';
  82. }
  83. return cssCls;
  84. },
  85. embedRowCls: function() {
  86. return '{rowCls}';
  87. },
  88. embedRowAttr: function() {
  89. return '{rowAttr}';
  90. },
  91. openTableWrap: function() {
  92. return '';
  93. },
  94. closeTableWrap: function() {
  95. return '';
  96. },
  97. getTableTpl: function(cfg, textOnly) {
  98. var tpl,
  99. tableTplMemberFns = {
  100. openRows: this.openRows,
  101. closeRows: this.closeRows,
  102. embedFeature: this.embedFeature,
  103. embedFullWidth: this.embedFullWidth,
  104. openTableWrap: this.openTableWrap,
  105. closeTableWrap: this.closeTableWrap
  106. },
  107. tplMemberFns = {},
  108. features = cfg.features || [],
  109. ln = features.length,
  110. i = 0,
  111. memberFns = {
  112. embedRowCls: this.embedRowCls,
  113. embedRowAttr: this.embedRowAttr,
  114. firstOrLastCls: this.firstOrLastCls
  115. },
  116. // copy the default
  117. metaRowTpl = Array.prototype.slice.call(this.metaRowTpl, 0),
  118. metaTableTpl;
  119. for (; i &lt; ln; i++) {
  120. if (!features[i].disabled) {
  121. features[i].mutateMetaRowTpl(metaRowTpl);
  122. Ext.apply(memberFns, features[i].getMetaRowTplFragments());
  123. Ext.apply(tplMemberFns, features[i].getFragmentTpl());
  124. Ext.apply(tableTplMemberFns, features[i].getTableFragments());
  125. }
  126. }
  127. metaRowTpl = Ext.create('Ext.XTemplate', metaRowTpl.join(''), memberFns);
  128. cfg.row = metaRowTpl.applyTemplate(cfg);
  129. metaTableTpl = Ext.create('Ext.XTemplate', this.metaTableTpl.join(''), tableTplMemberFns);
  130. tpl = metaTableTpl.applyTemplate(cfg);
  131. // TODO: Investigate eliminating.
  132. if (!textOnly) {
  133. tpl = Ext.create('Ext.XTemplate', tpl, tplMemberFns);
  134. }
  135. return tpl;
  136. }
  137. });
  138. </pre>
  139. </body>
  140. </html>