Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2527 lines
85 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. <div id="cls-Ext.grid.GridView"></div>/**
  16. * @class Ext.grid.GridView
  17. * @extends Ext.util.Observable
  18. * <p>This class encapsulates the user interface of an {@link Ext.grid.GridPanel}.
  19. * Methods of this class may be used to access user interface elements to enable
  20. * special display effects. Do not change the DOM structure of the user interface.</p>
  21. * <p>This class does not provide ways to manipulate the underlying data. The data
  22. * model of a Grid is held in an {@link Ext.data.Store}.</p>
  23. * @constructor
  24. * @param {Object} config
  25. */
  26. Ext.grid.GridView = Ext.extend(Ext.util.Observable, {
  27. <div id="method-Ext.grid.GridView-getRowClass"></div>/**
  28. * Override this function to apply custom CSS classes to rows during rendering. You can also supply custom
  29. * parameters to the row template for the current row to customize how it is rendered using the <b>rowParams</b>
  30. * parameter. This function should return the CSS class name (or empty string '' for none) that will be added
  31. * to the row's wrapping div. To apply multiple class names, simply return them space-delimited within the string
  32. * (e.g., 'my-class another-class'). Example usage:
  33. <pre><code>
  34. viewConfig: {
  35. forceFit: true,
  36. showPreview: true, // custom property
  37. enableRowBody: true, // required to create a second, full-width row to show expanded Record data
  38. getRowClass: function(record, rowIndex, rp, ds){ // rp = rowParams
  39. if(this.showPreview){
  40. rp.body = '&lt;p>'+record.data.excerpt+'&lt;/p>';
  41. return 'x-grid3-row-expanded';
  42. }
  43. return 'x-grid3-row-collapsed';
  44. }
  45. },
  46. </code></pre>
  47. * @param {Record} record The {@link Ext.data.Record} corresponding to the current row.
  48. * @param {Number} index The row index.
  49. * @param {Object} rowParams A config object that is passed to the row template during rendering that allows
  50. * customization of various aspects of a grid row.
  51. * <p>If {@link #enableRowBody} is configured <b><tt></tt>true</b>, then the following properties may be set
  52. * by this function, and will be used to render a full-width expansion row below each grid row:</p>
  53. * <ul>
  54. * <li><code>body</code> : String <div class="sub-desc">An HTML fragment to be used as the expansion row's body content (defaults to '').</div></li>
  55. * <li><code>bodyStyle</code> : String <div class="sub-desc">A CSS style specification that will be applied to the expansion row's &lt;tr> element. (defaults to '').</div></li>
  56. * </ul>
  57. * The following property will be passed in, and may be appended to:
  58. * <ul>
  59. * <li><code>tstyle</code> : String <div class="sub-desc">A CSS style specification that willl be applied to the &lt;table> element which encapsulates
  60. * both the standard grid row, and any expansion row.</div></li>
  61. * </ul>
  62. * @param {Store} store The {@link Ext.data.Store} this grid is bound to
  63. * @method getRowClass
  64. * @return {String} a CSS class name to add to the row.
  65. */
  66. <div id="cfg-Ext.grid.GridView-enableRowBody"></div>/**
  67. * @cfg {Boolean} enableRowBody True to add a second TR element per row that can be used to provide a row body
  68. * that spans beneath the data row. Use the {@link #getRowClass} method's rowParams config to customize the row body.
  69. */
  70. <div id="cfg-Ext.grid.GridView-emptyText"></div>/**
  71. * @cfg {String} emptyText Default text (html tags are accepted) to display in the grid body when no rows
  72. * are available (defaults to ''). This value will be used to update the <tt>{@link #mainBody}</tt>:
  73. <pre><code>
  74. this.mainBody.update('&lt;div class="x-grid-empty">' + this.emptyText + '&lt;/div>');
  75. </code></pre>
  76. */
  77. <div id="cfg-Ext.grid.GridView-headersDisabled"></div>/**
  78. * @cfg {Boolean} headersDisabled True to disable the grid column headers (defaults to <tt>false</tt>).
  79. * Use the {@link Ext.grid.ColumnModel ColumnModel} <tt>{@link Ext.grid.ColumnModel#menuDisabled menuDisabled}</tt>
  80. * config to disable the <i>menu</i> for individual columns. While this config is true the
  81. * following will be disabled:<div class="mdetail-params"><ul>
  82. * <li>clicking on header to sort</li>
  83. * <li>the trigger to reveal the menu.</li>
  84. * </ul></div>
  85. */
  86. <div id="prop-Ext.grid.GridView-dragZone"></div>/**
  87. * <p>A customized implementation of a {@link Ext.dd.DragZone DragZone} which provides default implementations
  88. * of the template methods of DragZone to enable dragging of the selected rows of a GridPanel.
  89. * See {@link Ext.grid.GridDragZone} for details.</p>
  90. * <p>This will <b>only</b> be present:<div class="mdetail-params"><ul>
  91. * <li><i>if</i> the owning GridPanel was configured with {@link Ext.grid.GridPanel#enableDragDrop enableDragDrop}: <tt>true</tt>.</li>
  92. * <li><i>after</i> the owning GridPanel has been rendered.</li>
  93. * </ul></div>
  94. * @property dragZone
  95. * @type {Ext.grid.GridDragZone}
  96. */
  97. <div id="cfg-Ext.grid.GridView-deferEmptyText"></div>/**
  98. * @cfg {Boolean} deferEmptyText True to defer <tt>{@link #emptyText}</tt> being applied until the store's
  99. * first load (defaults to <tt>true</tt>).
  100. */
  101. deferEmptyText : true,
  102. <div id="cfg-Ext.grid.GridView-scrollOffset"></div>/**
  103. * @cfg {Number} scrollOffset The amount of space to reserve for the vertical scrollbar
  104. * (defaults to <tt>undefined</tt>). If an explicit value isn't specified, this will be automatically
  105. * calculated.
  106. */
  107. scrollOffset : undefined,
  108. <div id="cfg-Ext.grid.GridView-autoFill"></div>/**
  109. * @cfg {Boolean} autoFill
  110. * Defaults to <tt>false</tt>. Specify <tt>true</tt> to have the column widths re-proportioned
  111. * when the grid is <b>initially rendered</b>. The
  112. * {@link Ext.grid.Column#width initially configured width}</tt> of each column will be adjusted
  113. * to fit the grid width and prevent horizontal scrolling. If columns are later resized (manually
  114. * or programmatically), the other columns in the grid will <b>not</b> be resized to fit the grid width.
  115. * See <tt>{@link #forceFit}</tt> also.
  116. */
  117. autoFill : false,
  118. <div id="cfg-Ext.grid.GridView-forceFit"></div>/**
  119. * @cfg {Boolean} forceFit
  120. * <p>Defaults to <tt>false</tt>. Specify <tt>true</tt> to have the column widths re-proportioned
  121. * at <b>all times</b>.</p>
  122. * <p>The {@link Ext.grid.Column#width initially configured width}</tt> of each
  123. * column will be adjusted to fit the grid width and prevent horizontal scrolling. If columns are
  124. * later resized (manually or programmatically), the other columns in the grid <b>will</b> be resized
  125. * to fit the grid width.</p>
  126. * <p>Columns which are configured with <code>fixed: true</code> are omitted from being resized.</p>
  127. * <p>See <tt>{@link #autoFill}</tt>.</p>
  128. */
  129. forceFit : false,
  130. <div id="cfg-Ext.grid.GridView-sortClasses"></div>/**
  131. * @cfg {Array} sortClasses The CSS classes applied to a header when it is sorted. (defaults to <tt>['sort-asc', 'sort-desc']</tt>)
  132. */
  133. sortClasses : ['sort-asc', 'sort-desc'],
  134. <div id="cfg-Ext.grid.GridView-sortAscText"></div>/**
  135. * @cfg {String} sortAscText The text displayed in the 'Sort Ascending' menu item (defaults to <tt>'Sort Ascending'</tt>)
  136. */
  137. sortAscText : 'Sort Ascending',
  138. <div id="cfg-Ext.grid.GridView-sortDescText"></div>/**
  139. * @cfg {String} sortDescText The text displayed in the 'Sort Descending' menu item (defaults to <tt>'Sort Descending'</tt>)
  140. */
  141. sortDescText : 'Sort Descending',
  142. <div id="cfg-Ext.grid.GridView-columnsText"></div>/**
  143. * @cfg {String} columnsText The text displayed in the 'Columns' menu item (defaults to <tt>'Columns'</tt>)
  144. */
  145. columnsText : 'Columns',
  146. <div id="cfg-Ext.grid.GridView-selectedRowClass"></div>/**
  147. * @cfg {String} selectedRowClass The CSS class applied to a selected row (defaults to <tt>'x-grid3-row-selected'</tt>). An
  148. * example overriding the default styling:
  149. <pre><code>
  150. .x-grid3-row-selected {background-color: yellow;}
  151. </code></pre>
  152. * Note that this only controls the row, and will not do anything for the text inside it. To style inner
  153. * facets (like text) use something like:
  154. <pre><code>
  155. .x-grid3-row-selected .x-grid3-cell-inner {
  156. color: #FFCC00;
  157. }
  158. </code></pre>
  159. * @type String
  160. */
  161. selectedRowClass : 'x-grid3-row-selected',
  162. // private
  163. borderWidth : 2,
  164. tdClass : 'x-grid3-cell',
  165. hdCls : 'x-grid3-hd',
  166. <div id="cfg-Ext.grid.GridView-markDirty"></div>/**
  167. * @cfg {Boolean} markDirty True to show the dirty cell indicator when a cell has been modified. Defaults to <tt>true</tt>.
  168. */
  169. markDirty : true,
  170. <div id="cfg-Ext.grid.GridView-cellSelectorDepth"></div>/**
  171. * @cfg {Number} cellSelectorDepth The number of levels to search for cells in event delegation (defaults to <tt>4</tt>)
  172. */
  173. cellSelectorDepth : 4,
  174. <div id="cfg-Ext.grid.GridView-rowSelectorDepth"></div>/**
  175. * @cfg {Number} rowSelectorDepth The number of levels to search for rows in event delegation (defaults to <tt>10</tt>)
  176. */
  177. rowSelectorDepth : 10,
  178. <div id="cfg-Ext.grid.GridView-rowBodySelectorDepth"></div>/**
  179. * @cfg {Number} rowBodySelectorDepth The number of levels to search for row bodies in event delegation (defaults to <tt>10</tt>)
  180. */
  181. rowBodySelectorDepth : 10,
  182. <div id="cfg-Ext.grid.GridView-cellSelector"></div>/**
  183. * @cfg {String} cellSelector The selector used to find cells internally (defaults to <tt>'td.x-grid3-cell'</tt>)
  184. */
  185. cellSelector : 'td.x-grid3-cell',
  186. <div id="cfg-Ext.grid.GridView-rowSelector"></div>/**
  187. * @cfg {String} rowSelector The selector used to find rows internally (defaults to <tt>'div.x-grid3-row'</tt>)
  188. */
  189. rowSelector : 'div.x-grid3-row',
  190. <div id="cfg-Ext.grid.GridView-rowBodySelector"></div>/**
  191. * @cfg {String} rowBodySelector The selector used to find row bodies internally (defaults to <tt>'div.x-grid3-row'</tt>)
  192. */
  193. rowBodySelector : 'div.x-grid3-row-body',
  194. // private
  195. firstRowCls: 'x-grid3-row-first',
  196. lastRowCls: 'x-grid3-row-last',
  197. rowClsRe: /(?:^|\s+)x-grid3-row-(first|last|alt)(?:\s+|$)/g,
  198. <div id="cfg-Ext.grid.GridView-headerMenuOpenCls"></div>/**
  199. * @cfg {String} headerMenuOpenCls The CSS class to add to the header cell when its menu is visible. Defaults to 'x-grid3-hd-menu-open'
  200. */
  201. headerMenuOpenCls: 'x-grid3-hd-menu-open',
  202. <div id="cfg-Ext.grid.GridView-rowOverCls"></div>/**
  203. * @cfg {String} rowOverCls The CSS class added to each row when it is hovered over. Defaults to 'x-grid3-row-over'
  204. */
  205. rowOverCls: 'x-grid3-row-over',
  206. constructor : function(config) {
  207. Ext.apply(this, config);
  208. // These events are only used internally by the grid components
  209. this.addEvents(
  210. <div id="event-Ext.grid.GridView-beforerowremoved"></div>/**
  211. * @event beforerowremoved
  212. * Internal UI Event. Fired before a row is removed.
  213. * @param {Ext.grid.GridView} view
  214. * @param {Number} rowIndex The index of the row to be removed.
  215. * @param {Ext.data.Record} record The Record to be removed
  216. */
  217. 'beforerowremoved',
  218. <div id="event-Ext.grid.GridView-beforerowsinserted"></div>/**
  219. * @event beforerowsinserted
  220. * Internal UI Event. Fired before rows are inserted.
  221. * @param {Ext.grid.GridView} view
  222. * @param {Number} firstRow The index of the first row to be inserted.
  223. * @param {Number} lastRow The index of the last row to be inserted.
  224. */
  225. 'beforerowsinserted',
  226. <div id="event-Ext.grid.GridView-beforerefresh"></div>/**
  227. * @event beforerefresh
  228. * Internal UI Event. Fired before the view is refreshed.
  229. * @param {Ext.grid.GridView} view
  230. */
  231. 'beforerefresh',
  232. <div id="event-Ext.grid.GridView-rowremoved"></div>/**
  233. * @event rowremoved
  234. * Internal UI Event. Fired after a row is removed.
  235. * @param {Ext.grid.GridView} view
  236. * @param {Number} rowIndex The index of the row that was removed.
  237. * @param {Ext.data.Record} record The Record that was removed
  238. */
  239. 'rowremoved',
  240. <div id="event-Ext.grid.GridView-rowsinserted"></div>/**
  241. * @event rowsinserted
  242. * Internal UI Event. Fired after rows are inserted.
  243. * @param {Ext.grid.GridView} view
  244. * @param {Number} firstRow The index of the first inserted.
  245. * @param {Number} lastRow The index of the last row inserted.
  246. */
  247. 'rowsinserted',
  248. <div id="event-Ext.grid.GridView-rowupdated"></div>/**
  249. * @event rowupdated
  250. * Internal UI Event. Fired after a row has been updated.
  251. * @param {Ext.grid.GridView} view
  252. * @param {Number} firstRow The index of the row updated.
  253. * @param {Ext.data.record} record The Record backing the row updated.
  254. */
  255. 'rowupdated',
  256. <div id="event-Ext.grid.GridView-refresh"></div>/**
  257. * @event refresh
  258. * Internal UI Event. Fired after the GridView's body has been refreshed.
  259. * @param {Ext.grid.GridView} view
  260. */
  261. 'refresh'
  262. );
  263. Ext.grid.GridView.superclass.constructor.call(this);
  264. },
  265. /* -------------------------------- UI Specific ----------------------------- */
  266. <div id="prop-Ext.grid.GridView-Ext.Template"></div>/**
  267. * The master template to use when rendering the GridView. Has a default template
  268. * @property Ext.Template
  269. * @type masterTpl
  270. */
  271. masterTpl: new Ext.Template(
  272. '<div class="x-grid3" hidefocus="true">',
  273. '<div class="x-grid3-viewport">',
  274. '<div class="x-grid3-header">',
  275. '<div class="x-grid3-header-inner">',
  276. '<div class="x-grid3-header-offset" style="{ostyle}">{header}</div>',
  277. '</div>',
  278. '<div class="x-clear"></div>',
  279. '</div>',
  280. '<div class="x-grid3-scroller">',
  281. '<div class="x-grid3-body" style="{bstyle}">{body}</div>',
  282. '<a href="#" class="x-grid3-focus" tabIndex="-1"></a>',
  283. '</div>',
  284. '</div>',
  285. '<div class="x-grid3-resize-marker">&#160;</div>',
  286. '<div class="x-grid3-resize-proxy">&#160;</div>',
  287. '</div>'
  288. ),
  289. <div id="prop-Ext.grid.GridView-headerTpl"></div>/**
  290. * The template to use when rendering headers. Has a default template
  291. * @property headerTpl
  292. * @type Ext.Template
  293. */
  294. headerTpl: new Ext.Template(
  295. '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
  296. '<thead>',
  297. '<tr class="x-grid3-hd-row">{cells}</tr>',
  298. '</thead>',
  299. '</table>'
  300. ),
  301. <div id="prop-Ext.grid.GridView-bodyTpl"></div>/**
  302. * The template to use when rendering the body. Has a default template
  303. * @property bodyTpl
  304. * @type Ext.Template
  305. */
  306. bodyTpl: new Ext.Template('{rows}'),
  307. <div id="prop-Ext.grid.GridView-cellTpl"></div>/**
  308. * The template to use to render each cell. Has a default template
  309. * @property cellTpl
  310. * @type Ext.Template
  311. */
  312. cellTpl: new Ext.Template(
  313. '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} {css}" style="{style}" tabIndex="0" {cellAttr}>',
  314. '<div class="x-grid3-cell-inner x-grid3-col-{id}" unselectable="on" {attr}>{value}</div>',
  315. '</td>'
  316. ),
  317. /**
  318. * @private
  319. * Provides default templates if they are not given for this particular instance. Most of the templates are defined on
  320. * the prototype, the ones defined inside this function are done so because they are based on Grid or GridView configuration
  321. */
  322. initTemplates : function() {
  323. var templates = this.templates || {},
  324. template, name,
  325. headerCellTpl = new Ext.Template(
  326. '<td class="x-grid3-hd x-grid3-cell x-grid3-td-{id} {css}" style="{style}">',
  327. '<div {tooltip} {attr} class="x-grid3-hd-inner x-grid3-hd-{id}" unselectable="on" style="{istyle}">',
  328. this.grid.enableHdMenu ? '<a class="x-grid3-hd-btn" href="#"></a>' : '',
  329. '{value}',
  330. '<img alt="" class="x-grid3-sort-icon" src="', Ext.BLANK_IMAGE_URL, '" />',
  331. '</div>',
  332. '</td>'
  333. ),
  334. rowBodyText = [
  335. '<tr class="x-grid3-row-body-tr" style="{bodyStyle}">',
  336. '<td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on">',
  337. '<div class="x-grid3-row-body">{body}</div>',
  338. '</td>',
  339. '</tr>'
  340. ].join(""),
  341. innerText = [
  342. '<table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
  343. '<tbody>',
  344. '<tr>{cells}</tr>',
  345. this.enableRowBody ? rowBodyText : '',
  346. '</tbody>',
  347. '</table>'
  348. ].join("");
  349. Ext.applyIf(templates, {
  350. hcell : headerCellTpl,
  351. cell : this.cellTpl,
  352. body : this.bodyTpl,
  353. header : this.headerTpl,
  354. master : this.masterTpl,
  355. row : new Ext.Template('<div class="x-grid3-row {alt}" style="{tstyle}">' + innerText + '</div>'),
  356. rowInner: new Ext.Template(innerText)
  357. });
  358. for (name in templates) {
  359. template = templates[name];
  360. if (template && Ext.isFunction(template.compile) && !template.compiled) {
  361. template.disableFormats = true;
  362. template.compile();
  363. }
  364. }
  365. this.templates = templates;
  366. this.colRe = new RegExp('x-grid3-td-([^\\s]+)', '');
  367. },
  368. /**
  369. * @private
  370. * Each GridView has its own private flyweight, accessed through this method
  371. */
  372. fly : function(el) {
  373. if (!this._flyweight) {
  374. this._flyweight = new Ext.Element.Flyweight(document.body);
  375. }
  376. this._flyweight.dom = el;
  377. return this._flyweight;
  378. },
  379. // private
  380. getEditorParent : function() {
  381. return this.scroller.dom;
  382. },
  383. /**
  384. * @private
  385. * Finds and stores references to important elements
  386. */
  387. initElements : function() {
  388. var Element = Ext.Element,
  389. el = Ext.get(this.grid.getGridEl().dom.firstChild),
  390. mainWrap = new Element(el.child('div.x-grid3-viewport')),
  391. mainHd = new Element(mainWrap.child('div.x-grid3-header')),
  392. scroller = new Element(mainWrap.child('div.x-grid3-scroller'));
  393. if (this.grid.hideHeaders) {
  394. mainHd.setDisplayed(false);
  395. }
  396. if (this.forceFit) {
  397. scroller.setStyle('overflow-x', 'hidden');
  398. }
  399. <div id="prop-Ext.grid.GridView-mainBody"></div>/**
  400. * <i>Read-only</i>. The GridView's body Element which encapsulates all rows in the Grid.
  401. * This {@link Ext.Element Element} is only available after the GridPanel has been rendered.
  402. * @type Ext.Element
  403. * @property mainBody
  404. */
  405. Ext.apply(this, {
  406. el : el,
  407. mainWrap: mainWrap,
  408. scroller: scroller,
  409. mainHd : mainHd,
  410. innerHd : mainHd.child('div.x-grid3-header-inner').dom,
  411. mainBody: new Element(Element.fly(scroller).child('div.x-grid3-body')),
  412. focusEl : new Element(Element.fly(scroller).child('a')),
  413. resizeMarker: new Element(el.child('div.x-grid3-resize-marker')),
  414. resizeProxy : new Element(el.child('div.x-grid3-resize-proxy'))
  415. });
  416. this.focusEl.swallowEvent('click', true);
  417. },
  418. // private
  419. getRows : function() {
  420. return this.hasRows() ? this.mainBody.dom.childNodes : [];
  421. },
  422. // finder methods, used with delegation
  423. // private
  424. findCell : function(el) {
  425. if (!el) {
  426. return false;
  427. }
  428. return this.fly(el).findParent(this.cellSelector, this.cellSelectorDepth);
  429. },
  430. <div id="method-Ext.grid.GridView-findCellIndex"></div>/**
  431. * <p>Return the index of the grid column which contains the passed HTMLElement.</p>
  432. * See also {@link #findRowIndex}
  433. * @param {HTMLElement} el The target element
  434. * @return {Number} The column index, or <b>false</b> if the target element is not within a row of this GridView.
  435. */
  436. findCellIndex : function(el, requiredCls) {
  437. var cell = this.findCell(el),
  438. hasCls;
  439. if (cell) {
  440. hasCls = this.fly(cell).hasClass(requiredCls);
  441. if (!requiredCls || hasCls) {
  442. return this.getCellIndex(cell);
  443. }
  444. }
  445. return false;
  446. },
  447. // private
  448. getCellIndex : function(el) {
  449. if (el) {
  450. var match = el.className.match(this.colRe);
  451. if (match && match[1]) {
  452. return this.cm.getIndexById(match[1]);
  453. }
  454. }
  455. return false;
  456. },
  457. // private
  458. findHeaderCell : function(el) {
  459. var cell = this.findCell(el);
  460. return cell && this.fly(cell).hasClass(this.hdCls) ? cell : null;
  461. },
  462. // private
  463. findHeaderIndex : function(el){
  464. return this.findCellIndex(el, this.hdCls);
  465. },
  466. <div id="method-Ext.grid.GridView-findRow"></div>/**
  467. * Return the HtmlElement representing the grid row which contains the passed element.
  468. * @param {HTMLElement} el The target HTMLElement
  469. * @return {HTMLElement} The row element, or null if the target element is not within a row of this GridView.
  470. */
  471. findRow : function(el) {
  472. if (!el) {
  473. return false;
  474. }
  475. return this.fly(el).findParent(this.rowSelector, this.rowSelectorDepth);
  476. },
  477. <div id="method-Ext.grid.GridView-findRowIndex"></div>/**
  478. * Return the index of the grid row which contains the passed HTMLElement.
  479. * See also {@link #findCellIndex}
  480. * @param {HTMLElement} el The target HTMLElement
  481. * @return {Number} The row index, or <b>false</b> if the target element is not within a row of this GridView.
  482. */
  483. findRowIndex : function(el) {
  484. var row = this.findRow(el);
  485. return row ? row.rowIndex : false;
  486. },
  487. <div id="method-Ext.grid.GridView-findRowBody"></div>/**
  488. * Return the HtmlElement representing the grid row body which contains the passed element.
  489. * @param {HTMLElement} el The target HTMLElement
  490. * @return {HTMLElement} The row body element, or null if the target element is not within a row body of this GridView.
  491. */
  492. findRowBody : function(el) {
  493. if (!el) {
  494. return false;
  495. }
  496. return this.fly(el).findParent(this.rowBodySelector, this.rowBodySelectorDepth);
  497. },
  498. // getter methods for fetching elements dynamically in the grid
  499. <div id="method-Ext.grid.GridView-getRow"></div>/**
  500. * Return the <tt>&lt;div></tt> HtmlElement which represents a Grid row for the specified index.
  501. * @param {Number} index The row index
  502. * @return {HtmlElement} The div element.
  503. */
  504. getRow : function(row) {
  505. return this.getRows()[row];
  506. },
  507. <div id="method-Ext.grid.GridView-getCell"></div>/**
  508. * Returns the grid's <tt>&lt;td></tt> HtmlElement at the specified coordinates.
  509. * @param {Number} row The row index in which to find the cell.
  510. * @param {Number} col The column index of the cell.
  511. * @return {HtmlElement} The td at the specified coordinates.
  512. */
  513. getCell : function(row, col) {
  514. return Ext.fly(this.getRow(row)).query(this.cellSelector)[col];
  515. },
  516. <div id="method-Ext.grid.GridView-getHeaderCell"></div>/**
  517. * Return the <tt>&lt;td></tt> HtmlElement which represents the Grid's header cell for the specified column index.
  518. * @param {Number} index The column index
  519. * @return {HtmlElement} The td element.
  520. */
  521. getHeaderCell : function(index) {
  522. return this.mainHd.dom.getElementsByTagName('td')[index];
  523. },
  524. // manipulating elements
  525. // private - use getRowClass to apply custom row classes
  526. addRowClass : function(rowId, cls) {
  527. var row = this.getRow(rowId);
  528. if (row) {
  529. this.fly(row).addClass(cls);
  530. }
  531. },
  532. // private
  533. removeRowClass : function(row, cls) {
  534. var r = this.getRow(row);
  535. if(r){
  536. this.fly(r).removeClass(cls);
  537. }
  538. },
  539. // private
  540. removeRow : function(row) {
  541. Ext.removeNode(this.getRow(row));
  542. this.syncFocusEl(row);
  543. },
  544. // private
  545. removeRows : function(firstRow, lastRow) {
  546. var bd = this.mainBody.dom,
  547. rowIndex;
  548. for (rowIndex = firstRow; rowIndex <= lastRow; rowIndex++){
  549. Ext.removeNode(bd.childNodes[firstRow]);
  550. }
  551. this.syncFocusEl(firstRow);
  552. },
  553. /* ----------------------------------- Scrolling functions -------------------------------------------*/
  554. // private
  555. getScrollState : function() {
  556. var sb = this.scroller.dom;
  557. return {
  558. left: sb.scrollLeft,
  559. top : sb.scrollTop
  560. };
  561. },
  562. // private
  563. restoreScroll : function(state) {
  564. var sb = this.scroller.dom;
  565. sb.scrollLeft = state.left;
  566. sb.scrollTop = state.top;
  567. },
  568. <div id="method-Ext.grid.GridView-scrollToTop"></div>/**
  569. * Scrolls the grid to the top
  570. */
  571. scrollToTop : function() {
  572. var dom = this.scroller.dom;
  573. dom.scrollTop = 0;
  574. dom.scrollLeft = 0;
  575. },
  576. // private
  577. syncScroll : function() {
  578. this.syncHeaderScroll();
  579. var mb = this.scroller.dom;
  580. this.grid.fireEvent('bodyscroll', mb.scrollLeft, mb.scrollTop);
  581. },
  582. // private
  583. syncHeaderScroll : function() {
  584. var innerHd = this.innerHd,
  585. scrollLeft = this.scroller.dom.scrollLeft;
  586. innerHd.scrollLeft = scrollLeft;
  587. innerHd.scrollLeft = scrollLeft; // second time for IE (1/2 time first fails, other browsers ignore)
  588. },
  589. /**
  590. * @private
  591. * Ensures the given column has the given icon class
  592. */
  593. updateSortIcon : function(col, dir) {
  594. var sortClasses = this.sortClasses,
  595. sortClass = sortClasses[dir == "DESC" ? 1 : 0],
  596. headers = this.mainHd.select('td').removeClass(sortClasses);
  597. headers.item(col).addClass(sortClass);
  598. },
  599. /**
  600. * @private
  601. * Updates the size of every column and cell in the grid
  602. */
  603. updateAllColumnWidths : function() {
  604. var totalWidth = this.getTotalWidth(),
  605. colCount = this.cm.getColumnCount(),
  606. rows = this.getRows(),
  607. rowCount = rows.length,
  608. widths = [],
  609. row, rowFirstChild, trow, i, j;
  610. for (i = 0; i < colCount; i++) {
  611. widths[i] = this.getColumnWidth(i);
  612. this.getHeaderCell(i).style.width = widths[i];
  613. }
  614. this.updateHeaderWidth();
  615. for (i = 0; i < rowCount; i++) {
  616. row = rows[i];
  617. row.style.width = totalWidth;
  618. rowFirstChild = row.firstChild;
  619. if (rowFirstChild) {
  620. rowFirstChild.style.width = totalWidth;
  621. trow = rowFirstChild.rows[0];
  622. for (j = 0; j < colCount; j++) {
  623. trow.childNodes[j].style.width = widths[j];
  624. }
  625. }
  626. }
  627. this.onAllColumnWidthsUpdated(widths, totalWidth);
  628. },
  629. /**
  630. * @private
  631. * Called after a column's width has been updated, this resizes all of the cells for that column in each row
  632. * @param {Number} column The column index
  633. */
  634. updateColumnWidth : function(column, width) {
  635. var columnWidth = this.getColumnWidth(column),
  636. totalWidth = this.getTotalWidth(),
  637. headerCell = this.getHeaderCell(column),
  638. nodes = this.getRows(),
  639. nodeCount = nodes.length,
  640. row, i, firstChild;
  641. this.updateHeaderWidth();
  642. headerCell.style.width = columnWidth;
  643. for (i = 0; i < nodeCount; i++) {
  644. row = nodes[i];
  645. firstChild = row.firstChild;
  646. row.style.width = totalWidth;
  647. if (firstChild) {
  648. firstChild.style.width = totalWidth;
  649. firstChild.rows[0].childNodes[column].style.width = columnWidth;
  650. }
  651. }
  652. this.onColumnWidthUpdated(column, columnWidth, totalWidth);
  653. },
  654. /**
  655. * @private
  656. * Sets the hidden status of a given column.
  657. * @param {Number} col The column index
  658. * @param {Boolean} hidden True to make the column hidden
  659. */
  660. updateColumnHidden : function(col, hidden) {
  661. var totalWidth = this.getTotalWidth(),
  662. display = hidden ? 'none' : '',
  663. headerCell = this.getHeaderCell(col),
  664. nodes = this.getRows(),
  665. nodeCount = nodes.length,
  666. row, rowFirstChild, i;
  667. this.updateHeaderWidth();
  668. headerCell.style.display = display;
  669. for (i = 0; i < nodeCount; i++) {
  670. row = nodes[i];
  671. row.style.width = totalWidth;
  672. rowFirstChild = row.firstChild;
  673. if (rowFirstChild) {
  674. rowFirstChild.style.width = totalWidth;
  675. rowFirstChild.rows[0].childNodes[col].style.display = display;
  676. }
  677. }
  678. this.onColumnHiddenUpdated(col, hidden, totalWidth);
  679. delete this.lastViewWidth; //recalc
  680. this.layout();
  681. },
  682. /**
  683. * @private
  684. * Renders all of the rows to a string buffer and returns the string. This is called internally
  685. * by renderRows and performs the actual string building for the rows - it does not inject HTML into the DOM.
  686. * @param {Array} columns The column data acquired from getColumnData.
  687. * @param {Array} records The array of records to render
  688. * @param {Ext.data.Store} store The store to render the rows from
  689. * @param {Number} startRow The index of the first row being rendered. Sometimes we only render a subset of
  690. * the rows so this is used to maintain logic for striping etc
  691. * @param {Number} colCount The total number of columns in the column model
  692. * @param {Boolean} stripe True to stripe the rows
  693. * @return {String} A string containing the HTML for the rendered rows
  694. */
  695. doRender : function(columns, records, store, startRow, colCount, stripe) {
  696. var templates = this.templates,
  697. cellTemplate = templates.cell,
  698. rowTemplate = templates.row,
  699. last = colCount - 1,
  700. tstyle = 'width:' + this.getTotalWidth() + ';',
  701. // buffers
  702. rowBuffer = [],
  703. colBuffer = [],
  704. rowParams = {tstyle: tstyle},
  705. meta = {},
  706. len = records.length,
  707. alt,
  708. column,
  709. record, i, j, rowIndex;
  710. //build up each row's HTML
  711. for (j = 0; j < len; j++) {
  712. record = records[j];
  713. colBuffer = [];
  714. rowIndex = j + startRow;
  715. //build up each column's HTML
  716. for (i = 0; i < colCount; i++) {
  717. column = columns[i];
  718. meta.id = column.id;
  719. meta.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
  720. meta.attr = meta.cellAttr = '';
  721. meta.style = column.style;
  722. meta.value = column.renderer.call(column.scope, record.data[column.name], meta, record, rowIndex, i, store);
  723. if (Ext.isEmpty(meta.value)) {
  724. meta.value = '&#160;';
  725. }
  726. if (this.markDirty && record.dirty && typeof record.modified[column.name] != 'undefined') {
  727. meta.css += ' x-grid3-dirty-cell';
  728. }
  729. colBuffer[colBuffer.length] = cellTemplate.apply(meta);
  730. }
  731. alt = [];
  732. //set up row striping and row dirtiness CSS classes
  733. if (stripe && ((rowIndex + 1) % 2 === 0)) {
  734. alt[0] = 'x-grid3-row-alt';
  735. }
  736. if (record.dirty) {
  737. alt[1] = ' x-grid3-dirty-row';
  738. }
  739. rowParams.cols = colCount;
  740. if (this.getRowClass) {
  741. alt[2] = this.getRowClass(record, rowIndex, rowParams, store);
  742. }
  743. rowParams.alt = alt.join(' ');
  744. rowParams.cells = colBuffer.join('');
  745. rowBuffer[rowBuffer.length] = rowTemplate.apply(rowParams);
  746. }
  747. return rowBuffer.join('');
  748. },
  749. /**
  750. * @private
  751. * Adds CSS classes and rowIndex to each row
  752. * @param {Number} startRow The row to start from (defaults to 0)
  753. */
  754. processRows : function(startRow, skipStripe) {
  755. if (!this.ds || this.ds.getCount() < 1) {
  756. return;
  757. }
  758. var rows = this.getRows(),
  759. length = rows.length,
  760. row, i;
  761. skipStripe = skipStripe || !this.grid.stripeRows;
  762. startRow = startRow || 0;
  763. for (i = 0; i < length; i++) {
  764. row = rows[i];
  765. if (row) {
  766. row.rowIndex = i;
  767. if (!skipStripe) {
  768. row.className = row.className.replace(this.rowClsRe, ' ');
  769. if ((i + 1) % 2 === 0){
  770. row.className += ' x-grid3-row-alt';
  771. }
  772. }
  773. }
  774. }
  775. // add first/last-row classes
  776. if (startRow === 0) {
  777. Ext.fly(rows[0]).addClass(this.firstRowCls);
  778. }
  779. Ext.fly(rows[length - 1]).addClass(this.lastRowCls);
  780. },
  781. /**
  782. * @private
  783. */
  784. afterRender : function() {
  785. if (!this.ds || !this.cm) {
  786. return;
  787. }
  788. this.mainBody.dom.innerHTML = this.renderBody() || '&#160;';
  789. this.processRows(0, true);
  790. if (this.deferEmptyText !== true) {
  791. this.applyEmptyText();
  792. }
  793. this.grid.fireEvent('viewready', this.grid);
  794. },
  795. /**
  796. * @private
  797. * This is always intended to be called after renderUI. Sets up listeners on the UI elements
  798. * and sets up options like column menus, moving and resizing.
  799. */
  800. afterRenderUI: function() {
  801. var grid = this.grid;
  802. this.initElements();
  803. // get mousedowns early
  804. Ext.fly(this.innerHd).on('click', this.handleHdDown, this);
  805. this.mainHd.on({
  806. scope : this,
  807. mouseover: this.handleHdOver,
  808. mouseout : this.handleHdOut,
  809. mousemove: this.handleHdMove
  810. });
  811. this.scroller.on('scroll', this.syncScroll, this);
  812. if (grid.enableColumnResize !== false) {
  813. this.splitZone = new Ext.grid.GridView.SplitDragZone(grid, this.mainHd.dom);
  814. }
  815. if (grid.enableColumnMove) {
  816. this.columnDrag = new Ext.grid.GridView.ColumnDragZone(grid, this.innerHd);
  817. this.columnDrop = new Ext.grid.HeaderDropZone(grid, this.mainHd.dom);
  818. }
  819. if (grid.enableHdMenu !== false) {
  820. this.hmenu = new Ext.menu.Menu({id: grid.id + '-hctx'});
  821. this.hmenu.add(
  822. {itemId:'asc', text: this.sortAscText, cls: 'xg-hmenu-sort-asc'},
  823. {itemId:'desc', text: this.sortDescText, cls: 'xg-hmenu-sort-desc'}
  824. );
  825. if (grid.enableColumnHide !== false) {
  826. this.colMenu = new Ext.menu.Menu({id:grid.id + '-hcols-menu'});
  827. this.colMenu.on({
  828. scope : this,
  829. beforeshow: this.beforeColMenuShow,
  830. itemclick : this.handleHdMenuClick
  831. });
  832. this.hmenu.add('-', {
  833. itemId:'columns',
  834. hideOnClick: false,
  835. text: this.columnsText,
  836. menu: this.colMenu,
  837. iconCls: 'x-cols-icon'
  838. });
  839. }
  840. this.hmenu.on('itemclick', this.handleHdMenuClick, this);
  841. }
  842. if (grid.trackMouseOver) {
  843. this.mainBody.on({
  844. scope : this,
  845. mouseover: this.onRowOver,
  846. mouseout : this.onRowOut
  847. });
  848. }
  849. if (grid.enableDragDrop || grid.enableDrag) {
  850. this.dragZone = new Ext.grid.GridDragZone(grid, {
  851. ddGroup : grid.ddGroup || 'GridDD'
  852. });
  853. }
  854. this.updateHeaderSortState();
  855. },
  856. /**
  857. * @private
  858. * Renders each of the UI elements in turn. This is called internally, once, by this.render. It does not
  859. * render rows from the store, just the surrounding UI elements.
  860. */
  861. renderUI : function() {
  862. var templates = this.templates;
  863. return templates.master.apply({
  864. body : templates.body.apply({rows:'&#160;'}),
  865. header: this.renderHeaders(),
  866. ostyle: 'width:' + this.getOffsetWidth() + ';',
  867. bstyle: 'width:' + this.getTotalWidth() + ';'
  868. });
  869. },
  870. // private
  871. processEvent : function(name, e) {
  872. var target = e.getTarget(),
  873. grid = this.grid,
  874. header = this.findHeaderIndex(target),
  875. row, cell, col, body;
  876. grid.fireEvent(name, e);
  877. if (header !== false) {
  878. grid.fireEvent('header' + name, grid, header, e);
  879. } else {
  880. row = this.findRowIndex(target);
  881. // Grid's value-added events must bubble correctly to allow cancelling via returning false: cell->column->row
  882. // We must allow a return of false at any of these levels to cancel the event processing.
  883. // Particularly allowing rowmousedown to be cancellable by prior handlers which need to prevent selection.
  884. if (row !== false) {
  885. cell = this.findCellIndex(target);
  886. if (cell !== false) {
  887. col = grid.colModel.getColumnAt(cell);
  888. if (grid.fireEvent('cell' + name, grid, row, cell, e) !== false) {
  889. if (!col || (col.processEvent && (col.processEvent(name, e, grid, row, cell) !== false))) {
  890. grid.fireEvent('row' + name, grid, row, e);
  891. }
  892. }
  893. } else {
  894. if (grid.fireEvent('row' + name, grid, row, e) !== false) {
  895. (body = this.findRowBody(target)) && grid.fireEvent('rowbody' + name, grid, row, e);
  896. }
  897. }
  898. } else {
  899. grid.fireEvent('container' + name, grid, e);
  900. }
  901. }
  902. },
  903. /**
  904. * @private
  905. * Sizes the grid's header and body elements
  906. */
  907. layout : function(initial) {
  908. if (!this.mainBody) {
  909. return; // not rendered
  910. }
  911. var grid = this.grid,
  912. gridEl = grid.getGridEl(),
  913. gridSize = gridEl.getSize(true),
  914. gridWidth = gridSize.width,
  915. gridHeight = gridSize.height,
  916. scroller = this.scroller,
  917. scrollStyle, headerHeight, scrollHeight;
  918. if (gridWidth < 20 || gridHeight < 20) {
  919. return;
  920. }
  921. if (grid.autoHeight) {
  922. scrollStyle = scroller.dom.style;
  923. scrollStyle.overflow = 'visible';
  924. if (Ext.isWebKit) {
  925. scrollStyle.position = 'static';
  926. }
  927. } else {
  928. this.el.setSize(gridWidth, gridHeight);
  929. headerHeight = this.mainHd.getHeight();
  930. scrollHeight = gridHeight - headerHeight;
  931. scroller.setSize(gridWidth, scrollHeight);
  932. if (this.innerHd) {
  933. this.innerHd.style.width = (gridWidth) + "px";
  934. }
  935. }
  936. if (this.forceFit || (initial === true && this.autoFill)) {
  937. if (this.lastViewWidth != gridWidth) {
  938. this.fitColumns(false, false);
  939. this.lastViewWidth = gridWidth;
  940. }
  941. } else {
  942. this.autoExpand();
  943. this.syncHeaderScroll();
  944. }
  945. this.onLayout(gridWidth, scrollHeight);
  946. },
  947. // template functions for subclasses and plugins
  948. // these functions include precalculated values
  949. onLayout : function(vw, vh) {
  950. // do nothing
  951. },
  952. onColumnWidthUpdated : function(col, w, tw) {
  953. //template method
  954. },
  955. onAllColumnWidthsUpdated : function(ws, tw) {
  956. //template method
  957. },
  958. onColumnHiddenUpdated : function(col, hidden, tw) {
  959. // template method
  960. },
  961. updateColumnText : function(col, text) {
  962. // template method
  963. },
  964. afterMove : function(colIndex) {
  965. // template method
  966. },
  967. /* ----------------------------------- Core Specific -------------------------------------------*/
  968. // private
  969. init : function(grid) {
  970. this.grid = grid;
  971. this.initTemplates();
  972. this.initData(grid.store, grid.colModel);
  973. this.initUI(grid);
  974. },
  975. // private
  976. getColumnId : function(index){
  977. return this.cm.getColumnId(index);
  978. },
  979. // private
  980. getOffsetWidth : function() {
  981. return (this.cm.getTotalWidth() + this.getScrollOffset()) + 'px';
  982. },
  983. // private
  984. getScrollOffset: function() {
  985. return Ext.num(this.scrollOffset, Ext.getScrollBarWidth());
  986. },
  987. /**
  988. * @private
  989. * Renders the header row using the 'header' template. Does not inject the HTML into the DOM, just
  990. * returns a string.
  991. * @return {String} Rendered header row
  992. */
  993. renderHeaders : function() {
  994. var colModel = this.cm,
  995. templates = this.templates,
  996. headerTpl = templates.hcell,
  997. properties = {},
  998. colCount = colModel.getColumnCount(),
  999. last = colCount - 1,
  1000. cells = [],
  1001. i, cssCls;
  1002. for (i = 0; i < colCount; i++) {
  1003. if (i == 0) {
  1004. cssCls = 'x-grid3-cell-first ';
  1005. } else {
  1006. cssCls = i == last ? 'x-grid3-cell-last ' : '';
  1007. }
  1008. properties = {
  1009. id : colModel.getColumnId(i),
  1010. value : colModel.getColumnHeader(i) || '',
  1011. style : this.getColumnStyle(i, true),
  1012. css : cssCls,
  1013. tooltip: this.getColumnTooltip(i)
  1014. };
  1015. if (colModel.config[i].align == 'right') {
  1016. properties.istyle = 'padding-right: 16px;';
  1017. } else {
  1018. delete properties.istyle;
  1019. }
  1020. cells[i] = headerTpl.apply(properties);
  1021. }
  1022. return templates.header.apply({
  1023. cells : cells.join(""),
  1024. tstyle: String.format("width: {0};", this.getTotalWidth())
  1025. });
  1026. },
  1027. /**
  1028. * @private
  1029. */
  1030. getColumnTooltip : function(i) {
  1031. var tooltip = this.cm.getColumnTooltip(i);
  1032. if (tooltip) {
  1033. if (Ext.QuickTips.isEnabled()) {
  1034. return 'ext:qtip="' + tooltip + '"';
  1035. } else {
  1036. return 'title="' + tooltip + '"';
  1037. }
  1038. }
  1039. return '';
  1040. },
  1041. // private
  1042. beforeUpdate : function() {
  1043. this.grid.stopEditing(true);
  1044. },
  1045. /**
  1046. * @private
  1047. * Re-renders the headers and ensures they are sized correctly
  1048. */
  1049. updateHeaders : function() {
  1050. this.innerHd.firstChild.innerHTML = this.renderHeaders();
  1051. this.updateHeaderWidth(false);
  1052. },
  1053. /**
  1054. * @private
  1055. * Ensures that the header is sized to the total width available to it
  1056. * @param {Boolean} updateMain True to update the mainBody's width also (defaults to true)
  1057. */
  1058. updateHeaderWidth: function(updateMain) {
  1059. var innerHdChild = this.innerHd.firstChild,
  1060. totalWidth = this.getTotalWidth();
  1061. innerHdChild.style.width = this.getOffsetWidth();
  1062. innerHdChild.firstChild.style.width = totalWidth;
  1063. if (updateMain !== false) {
  1064. this.mainBody.dom.style.width = totalWidth;
  1065. }
  1066. },
  1067. <div id="method-Ext.grid.GridView-focusRow"></div>/**
  1068. * Focuses the specified row.
  1069. * @param {Number} row The row index
  1070. */
  1071. focusRow : function(row) {
  1072. this.focusCell(row, 0, false);
  1073. },
  1074. <div id="method-Ext.grid.GridView-focusCell"></div>/**
  1075. * Focuses the specified cell.
  1076. * @param {Number} row The row index
  1077. * @param {Number} col The column index
  1078. */
  1079. focusCell : function(row, col, hscroll) {
  1080. this.syncFocusEl(this.ensureVisible(row, col, hscroll));
  1081. var focusEl = this.focusEl;
  1082. if (Ext.isGecko) {
  1083. focusEl.focus();
  1084. } else {
  1085. focusEl.focus.defer(1, focusEl);
  1086. }
  1087. },
  1088. /**
  1089. * @private
  1090. * Finds the Elements corresponding to the given row and column indexes
  1091. */
  1092. resolveCell : function(row, col, hscroll) {
  1093. if (!Ext.isNumber(row)) {
  1094. row = row.rowIndex;
  1095. }
  1096. if (!this.ds) {
  1097. return null;
  1098. }
  1099. if (row < 0 || row >= this.ds.getCount()) {
  1100. return null;
  1101. }
  1102. col = (col !== undefined ? col : 0);
  1103. var rowEl = this.getRow(row),
  1104. colModel = this.cm,
  1105. colCount = colModel.getColumnCount(),
  1106. cellEl;
  1107. if (!(hscroll === false && col === 0)) {
  1108. while (col < colCount && colModel.isHidden(col)) {
  1109. col++;
  1110. }
  1111. cellEl = this.getCell(row, col);
  1112. }
  1113. return {row: rowEl, cell: cellEl};
  1114. },
  1115. /**
  1116. * @private
  1117. * Returns the XY co-ordinates of a given row/cell resolution (see {@link #resolveCell})
  1118. * @return {Array} X and Y coords
  1119. */
  1120. getResolvedXY : function(resolved) {
  1121. if (!resolved) {
  1122. return null;
  1123. }
  1124. var cell = resolved.cell,
  1125. row = resolved.row;
  1126. if (cell) {
  1127. return Ext.fly(cell).getXY();
  1128. } else {
  1129. return [this.el.getX(), Ext.fly(row).getY()];
  1130. }
  1131. },
  1132. /**
  1133. * @private
  1134. * Moves the focus element to the x and y co-ordinates of the given row and column
  1135. */
  1136. syncFocusEl : function(row, col, hscroll) {
  1137. var xy = row;
  1138. if (!Ext.isArray(xy)) {
  1139. row = Math.min(row, Math.max(0, this.getRows().length-1));
  1140. if (isNaN(row)) {
  1141. return;
  1142. }
  1143. xy = this.getResolvedXY(this.resolveCell(row, col, hscroll));
  1144. }
  1145. this.focusEl.setXY(xy || this.scroller.getXY());
  1146. },
  1147. /**
  1148. * @private
  1149. */
  1150. ensureVisible : function(row, col, hscroll) {
  1151. var resolved = this.resolveCell(row, col, hscroll);
  1152. if (!resolved || !resolved.row) {
  1153. return null;
  1154. }
  1155. var rowEl = resolved.row,
  1156. cellEl = resolved.cell,
  1157. c = this.scroller.dom,
  1158. p = rowEl,
  1159. ctop = 0,
  1160. stop = this.el.dom;
  1161. while (p && p != stop) {
  1162. ctop += p.offsetTop;
  1163. p = p.offsetParent;
  1164. }
  1165. ctop -= this.mainHd.dom.offsetHeight;
  1166. stop = parseInt(c.scrollTop, 10);
  1167. var cbot = ctop + rowEl.offsetHeight,
  1168. ch = c.clientHeight,
  1169. sbot = stop + ch;
  1170. if (ctop < stop) {
  1171. c.scrollTop = ctop;
  1172. } else if(cbot > sbot) {
  1173. c.scrollTop = cbot-ch;
  1174. }
  1175. if (hscroll !== false) {
  1176. var cleft = parseInt(cellEl.offsetLeft, 10),
  1177. cright = cleft + cellEl.offsetWidth,
  1178. sleft = parseInt(c.scrollLeft, 10),
  1179. sright = sleft + c.clientWidth;
  1180. if (cleft < sleft) {
  1181. c.scrollLeft = cleft;
  1182. } else if(cright > sright) {
  1183. c.scrollLeft = cright-c.clientWidth;
  1184. }
  1185. }
  1186. return this.getResolvedXY(resolved);
  1187. },
  1188. // private
  1189. insertRows : function(dm, firstRow, lastRow, isUpdate) {
  1190. var last = dm.getCount() - 1;
  1191. if( !isUpdate && firstRow === 0 && lastRow >= last) {
  1192. this.fireEvent('beforerowsinserted', this, firstRow, lastRow);
  1193. this.refresh();
  1194. this.fireEvent('rowsinserted', this, firstRow, lastRow);
  1195. } else {
  1196. if (!isUpdate) {
  1197. this.fireEvent('beforerowsinserted', this, firstRow, lastRow);
  1198. }
  1199. var html = this.renderRows(firstRow, lastRow),
  1200. before = this.getRow(firstRow);
  1201. if (before) {
  1202. if(firstRow === 0){
  1203. Ext.fly(this.getRow(0)).removeClass(this.firstRowCls);
  1204. }
  1205. Ext.DomHelper.insertHtml('beforeBegin', before, html);
  1206. } else {
  1207. var r = this.getRow(last - 1);
  1208. if(r){
  1209. Ext.fly(r).removeClass(this.lastRowCls);
  1210. }
  1211. Ext.DomHelper.insertHtml('beforeEnd', this.mainBody.dom, html);
  1212. }
  1213. if (!isUpdate) {
  1214. this.processRows(firstRow);
  1215. this.fireEvent('rowsinserted', this, firstRow, lastRow);
  1216. } else if (firstRow === 0 || firstRow >= last) {
  1217. //ensure first/last row is kept after an update.
  1218. Ext.fly(this.getRow(firstRow)).addClass(firstRow === 0 ? this.firstRowCls : this.lastRowCls);
  1219. }
  1220. }
  1221. this.syncFocusEl(firstRow);
  1222. },
  1223. /**
  1224. * @private
  1225. * DEPRECATED - this doesn't appear to be called anywhere in the library, remove in 4.0.
  1226. */
  1227. deleteRows : function(dm, firstRow, lastRow) {
  1228. if (dm.getRowCount() < 1) {
  1229. this.refresh();
  1230. } else {
  1231. this.fireEvent('beforerowsdeleted', this, firstRow, lastRow);
  1232. this.removeRows(firstRow, lastRow);
  1233. this.processRows(firstRow);
  1234. this.fireEvent('rowsdeleted', this, firstRow, lastRow);
  1235. }
  1236. },
  1237. /**
  1238. * @private
  1239. * Builds a CSS string for the given column index
  1240. * @param {Number} colIndex The column index
  1241. * @param {Boolean} isHeader True if getting the style for the column's header
  1242. * @return {String} The CSS string
  1243. */
  1244. getColumnStyle : function(colIndex, isHeader) {
  1245. var colModel = this.cm,
  1246. colConfig = colModel.config,
  1247. style = isHeader ? '' : colConfig[colIndex].css || '',
  1248. align = colConfig[colIndex].align;
  1249. style += String.format("width: {0};", this.getColumnWidth(colIndex));
  1250. if (colModel.isHidden(colIndex)) {
  1251. style += 'display: none; ';
  1252. }
  1253. if (align) {
  1254. style += String.format("text-align: {0};", align);
  1255. }
  1256. return style;
  1257. },
  1258. /**
  1259. * @private
  1260. * Returns the width of a given column minus its border width
  1261. * @return {Number} The column index
  1262. * @return {String|Number} The width in pixels
  1263. */
  1264. getColumnWidth : function(column) {
  1265. var columnWidth = this.cm.getColumnWidth(column),
  1266. borderWidth = this.borderWidth;
  1267. if (Ext.isNumber(columnWidth)) {
  1268. if (Ext.isBorderBox || (Ext.isWebKit && !Ext.isSafari2)) {
  1269. return columnWidth + "px";
  1270. } else {
  1271. return Math.max(columnWidth - borderWidth, 0) + "px";
  1272. }
  1273. } else {
  1274. return columnWidth;
  1275. }
  1276. },
  1277. /**
  1278. * @private
  1279. * Returns the total width of all visible columns
  1280. * @return {String}
  1281. */
  1282. getTotalWidth : function() {
  1283. return this.cm.getTotalWidth() + 'px';
  1284. },
  1285. /**
  1286. * @private
  1287. * Resizes each column to fit the available grid width.
  1288. * TODO: The second argument isn't even used, remove it in 4.0
  1289. * @param {Boolean} preventRefresh True to prevent resizing of each row to the new column sizes (defaults to false)
  1290. * @param {null} onlyExpand NOT USED, will be removed in 4.0
  1291. * @param {Number} omitColumn The index of a column to leave at its current width. Defaults to undefined
  1292. * @return {Boolean} True if the operation succeeded, false if not or undefined if the grid view is not yet initialized
  1293. */
  1294. fitColumns : function(preventRefresh, onlyExpand, omitColumn) {
  1295. var grid = this.grid,
  1296. colModel = this.cm,
  1297. totalColWidth = colModel.getTotalWidth(false),
  1298. gridWidth = this.getGridInnerWidth(),
  1299. extraWidth = gridWidth - totalColWidth,
  1300. columns = [],
  1301. extraCol = 0,
  1302. width = 0,
  1303. colWidth, fraction, i;
  1304. // not initialized, so don't screw up the default widths
  1305. if (gridWidth < 20 || extraWidth === 0) {
  1306. return false;
  1307. }
  1308. var visibleColCount = colModel.getColumnCount(true),
  1309. totalColCount = colModel.getColumnCount(false),
  1310. adjCount = visibleColCount - (Ext.isNumber(omitColumn) ? 1 : 0);
  1311. if (adjCount === 0) {
  1312. adjCount = 1;
  1313. omitColumn = undefined;
  1314. }
  1315. //FIXME: the algorithm used here is odd and potentially confusing. Includes this for loop and the while after it.
  1316. for (i = 0; i < totalColCount; i++) {
  1317. if (!colModel.isFixed(i) && i !== omitColumn) {
  1318. colWidth = colModel.getColumnWidth(i);
  1319. columns.push(i, colWidth);
  1320. if (!colModel.isHidden(i)) {
  1321. extraCol = i;
  1322. width += colWidth;
  1323. }
  1324. }
  1325. }
  1326. fraction = (gridWidth - colModel.getTotalWidth()) / width;
  1327. while (columns.length) {
  1328. colWidth = columns.pop();
  1329. i = columns.pop();
  1330. colModel.setColumnWidth(i, Math.max(grid.minColumnWidth, Math.floor(colWidth + colWidth * fraction)), true);
  1331. }
  1332. //this has been changed above so remeasure now
  1333. totalColWidth = colModel.getTotalWidth(false);
  1334. if (totalColWidth > gridWidth) {
  1335. var adjustCol = (adjCount == visibleColCount) ? extraCol : omitColumn,
  1336. newWidth = Math.max(1, colModel.getColumnWidth(adjustCol) - (totalColWidth - gridWidth));
  1337. colModel.setColumnWidth(adjustCol, newWidth, true);
  1338. }
  1339. if (preventRefresh !== true) {
  1340. this.updateAllColumnWidths();
  1341. }
  1342. return true;
  1343. },
  1344. /**
  1345. * @private
  1346. * Resizes the configured autoExpandColumn to take the available width after the other columns have
  1347. * been accounted for
  1348. * @param {Boolean} preventUpdate True to prevent the resizing of all rows (defaults to false)
  1349. */
  1350. autoExpand : function(preventUpdate) {
  1351. var grid = this.grid,
  1352. colModel = this.cm,
  1353. gridWidth = this.getGridInnerWidth(),
  1354. totalColumnWidth = colModel.getTotalWidth(false),
  1355. autoExpandColumn = grid.autoExpandColumn;
  1356. if (!this.userResized && autoExpandColumn) {
  1357. if (gridWidth != totalColumnWidth) {
  1358. //if we are not already using all available width, resize the autoExpandColumn
  1359. var colIndex = colModel.getIndexById(autoExpandColumn),
  1360. currentWidth = colModel.getColumnWidth(colIndex),
  1361. desiredWidth = gridWidth - totalColumnWidth + currentWidth,
  1362. newWidth = Math.min(Math.max(desiredWidth, grid.autoExpandMin), grid.autoExpandMax);
  1363. if (currentWidth != newWidth) {
  1364. colModel.setColumnWidth(colIndex, newWidth, true);
  1365. if (preventUpdate !== true) {
  1366. this.updateColumnWidth(colIndex, newWidth);
  1367. }
  1368. }
  1369. }
  1370. }
  1371. },
  1372. <div id="method-Ext.grid.GridView-getGridInnerWidth"></div>/**
  1373. * Returns the total internal width available to the grid, taking the scrollbar into account
  1374. * @return {Number} The total width
  1375. */
  1376. getGridInnerWidth: function() {
  1377. return this.grid.getGridEl().getWidth(true) - this.getScrollOffset();
  1378. },
  1379. /**
  1380. * @private
  1381. * Returns an array of column configurations - one for each column
  1382. * @return {Array} Array of column config objects. This includes the column name, renderer, id style and renderer
  1383. */
  1384. getColumnData : function() {
  1385. var columns = [],
  1386. colModel = this.cm,
  1387. colCount = colModel.getColumnCount(),
  1388. fields = this.ds.fields,
  1389. i, name;
  1390. for (i = 0; i < colCount; i++) {
  1391. name = colModel.getDataIndex(i);
  1392. columns[i] = {
  1393. name : Ext.isDefined(name) ? name : (fields.get(i) ? fields.get(i).name : undefined),
  1394. renderer: colModel.getRenderer(i),
  1395. scope : colModel.getRendererScope(i),
  1396. id : colModel.getColumnId(i),
  1397. style : this.getColumnStyle(i)
  1398. };
  1399. }
  1400. return columns;
  1401. },
  1402. /**
  1403. * @private
  1404. * Renders rows between start and end indexes
  1405. * @param {Number} startRow Index of the first row to render
  1406. * @param {Number} endRow Index of the last row to render
  1407. */
  1408. renderRows : function(startRow, endRow) {
  1409. var grid = this.grid,
  1410. store = grid.store,
  1411. stripe = grid.stripeRows,
  1412. colModel = grid.colModel,
  1413. colCount = colModel.getColumnCount(),
  1414. rowCount = store.getCount(),
  1415. records;
  1416. if (rowCount < 1) {
  1417. return '';
  1418. }
  1419. startRow = startRow || 0;
  1420. endRow = Ext.isDefined(endRow) ? endRow : rowCount - 1;
  1421. records = store.getRange(startRow, endRow);
  1422. return this.doRender(this.getColumnData(), records, store, startRow, colCount, stripe);
  1423. },
  1424. // private
  1425. renderBody : function(){
  1426. var markup = this.renderRows() || '&#160;';
  1427. return this.templates.body.apply({rows: markup});
  1428. },
  1429. /**
  1430. * @private
  1431. * Refreshes a row by re-rendering it. Fires the rowupdated event when done
  1432. */
  1433. refreshRow: function(record) {
  1434. var store = this.ds,
  1435. colCount = this.cm.getColumnCount(),
  1436. columns = this.getColumnData(),
  1437. last = colCount - 1,
  1438. cls = ['x-grid3-row'],
  1439. rowParams = {
  1440. tstyle: String.format("width: {0};", this.getTotalWidth())
  1441. },
  1442. colBuffer = [],
  1443. cellTpl = this.templates.cell,
  1444. rowIndex, row, column, meta, css, i;
  1445. if (Ext.isNumber(record)) {
  1446. rowIndex = record;
  1447. record = store.getAt(rowIndex);
  1448. } else {
  1449. rowIndex = store.indexOf(record);
  1450. }
  1451. //the record could not be found
  1452. if (!record || rowIndex < 0) {
  1453. return;
  1454. }
  1455. //builds each column in this row
  1456. for (i = 0; i < colCount; i++) {
  1457. column = columns[i];
  1458. if (i == 0) {
  1459. css = 'x-grid3-cell-first';
  1460. } else {
  1461. css = (i == last) ? 'x-grid3-cell-last ' : '';
  1462. }
  1463. meta = {
  1464. id : column.id,
  1465. style : column.style,
  1466. css : css,
  1467. attr : "",
  1468. cellAttr: ""
  1469. };
  1470. // Need to set this after, because we pass meta to the renderer
  1471. meta.value = column.renderer.call(column.scope, record.data[column.name], meta, record, rowIndex, i, store);
  1472. if (Ext.isEmpty(meta.value)) {
  1473. meta.value = '&#160;';
  1474. }
  1475. if (this.markDirty && record.dirty && typeof record.modified[column.name] != 'undefined') {
  1476. meta.css += ' x-grid3-dirty-cell';
  1477. }
  1478. colBuffer[i] = cellTpl.apply(meta);
  1479. }
  1480. row = this.getRow(rowIndex);
  1481. row.className = '';
  1482. if (this.grid.stripeRows && ((rowIndex + 1) % 2 === 0)) {
  1483. cls.push('x-grid3-row-alt');
  1484. }
  1485. if (this.getRowClass) {
  1486. rowParams.cols = colCount;
  1487. cls.push(this.getRowClass(record, rowIndex, rowParams, store));
  1488. }
  1489. this.fly(row).addClass(cls).setStyle(rowParams.tstyle);
  1490. rowParams.cells = colBuffer.join("");
  1491. row.innerHTML = this.templates.rowInner.apply(rowParams);
  1492. this.fireEvent('rowupdated', this, rowIndex, record);
  1493. },
  1494. <div id="method-Ext.grid.GridView-refresh"></div>/**
  1495. * Refreshs the grid UI
  1496. * @param {Boolean} headersToo (optional) True to also refresh the headers
  1497. */
  1498. refresh : function(headersToo) {
  1499. this.fireEvent('beforerefresh', this);
  1500. this.grid.stopEditing(true);
  1501. var result = this.renderBody();
  1502. this.mainBody.update(result).setWidth(this.getTotalWidth());
  1503. if (headersToo === true) {
  1504. this.updateHeaders();
  1505. this.updateHeaderSortState();
  1506. }
  1507. this.processRows(0, true);
  1508. this.layout();
  1509. this.applyEmptyText();
  1510. this.fireEvent('refresh', this);
  1511. },
  1512. /**
  1513. * @private
  1514. * Displays the configured emptyText if there are currently no rows to display
  1515. */
  1516. applyEmptyText : function() {
  1517. if (this.emptyText && !this.hasRows()) {
  1518. this.mainBody.update('<div class="x-grid-empty">' + this.emptyText + '</div>');
  1519. }
  1520. },
  1521. /**
  1522. * @private
  1523. * Adds sorting classes to the column headers based on the bound store's sortInfo. Fires the 'sortchange' event
  1524. * if the sorting has changed since this function was last run.
  1525. */
  1526. updateHeaderSortState : function() {
  1527. var state = this.ds.getSortState();
  1528. if (!state) {
  1529. return;
  1530. }
  1531. if (!this.sortState || (this.sortState.field != state.field || this.sortState.direction != state.direction)) {
  1532. this.grid.fireEvent('sortchange', this.grid, state);
  1533. }
  1534. this.sortState = state;
  1535. var sortColumn = this.cm.findColumnIndex(state.field);
  1536. if (sortColumn != -1) {
  1537. var sortDir = state.direction;
  1538. this.updateSortIcon(sortColumn, sortDir);
  1539. }
  1540. },
  1541. /**
  1542. * @private
  1543. * Removes any sorting indicator classes from the column headers
  1544. */
  1545. clearHeaderSortState : function() {
  1546. if (!this.sortState) {
  1547. return;
  1548. }
  1549. this.grid.fireEvent('sortchange', this.grid, null);
  1550. this.mainHd.select('td').removeClass(this.sortClasses);
  1551. delete this.sortState;
  1552. },
  1553. /**
  1554. * @private
  1555. * Destroys all objects associated with the GridView
  1556. */
  1557. destroy : function() {
  1558. var me = this,
  1559. grid = me.grid,
  1560. gridEl = grid.getGridEl(),
  1561. dragZone = me.dragZone,
  1562. splitZone = me.splitZone,
  1563. columnDrag = me.columnDrag,
  1564. columnDrop = me.columnDrop,
  1565. scrollToTopTask = me.scrollToTopTask,
  1566. columnDragData,
  1567. columnDragProxy;
  1568. if (scrollToTopTask && scrollToTopTask.cancel) {
  1569. scrollToTopTask.cancel();
  1570. }
  1571. Ext.destroyMembers(me, 'colMenu', 'hmenu');
  1572. me.initData(null, null);
  1573. me.purgeListeners();
  1574. Ext.fly(me.innerHd).un("click", me.handleHdDown, me);
  1575. if (grid.enableColumnMove) {
  1576. columnDragData = columnDrag.dragData;
  1577. columnDragProxy = columnDrag.proxy;
  1578. Ext.destroy(
  1579. columnDrag.el,
  1580. columnDragProxy.ghost,
  1581. columnDragProxy.el,
  1582. columnDrop.el,
  1583. columnDrop.proxyTop,
  1584. columnDrop.proxyBottom,
  1585. columnDragData.ddel,
  1586. columnDragData.header
  1587. );
  1588. if (columnDragProxy.anim) {
  1589. Ext.destroy(columnDragProxy.anim);
  1590. }
  1591. delete columnDragProxy.ghost;
  1592. delete columnDragData.ddel;
  1593. delete columnDragData.header;
  1594. columnDrag.destroy();
  1595. delete Ext.dd.DDM.locationCache[columnDrag.id];
  1596. delete columnDrag._domRef;
  1597. delete columnDrop.proxyTop;
  1598. delete columnDrop.proxyBottom;
  1599. columnDrop.destroy();
  1600. delete Ext.dd.DDM.locationCache["gridHeader" + gridEl.id];
  1601. delete columnDrop._domRef;
  1602. delete Ext.dd.DDM.ids[columnDrop.ddGroup];
  1603. }
  1604. if (splitZone) { // enableColumnResize
  1605. splitZone.destroy();
  1606. delete splitZone._domRef;
  1607. delete Ext.dd.DDM.ids["gridSplitters" + gridEl.id];
  1608. }
  1609. Ext.fly(me.innerHd).removeAllListeners();
  1610. Ext.removeNode(me.innerHd);
  1611. delete me.innerHd;
  1612. Ext.destroy(
  1613. me.el,
  1614. me.mainWrap,
  1615. me.mainHd,
  1616. me.scroller,
  1617. me.mainBody,
  1618. me.focusEl,
  1619. me.resizeMarker,
  1620. me.resizeProxy,
  1621. me.activeHdBtn,
  1622. me._flyweight,
  1623. dragZone,
  1624. splitZone
  1625. );
  1626. delete grid.container;
  1627. if (dragZone) {
  1628. dragZone.destroy();
  1629. }
  1630. Ext.dd.DDM.currentTarget = null;
  1631. delete Ext.dd.DDM.locationCache[gridEl.id];
  1632. Ext.EventManager.removeResizeListener(me.onWindowResize, me);
  1633. },
  1634. // private
  1635. onDenyColumnHide : function() {
  1636. },
  1637. // private
  1638. render : function() {
  1639. if (this.autoFill) {
  1640. var ct = this.grid.ownerCt;
  1641. if (ct && ct.getLayout()) {
  1642. ct.on('afterlayout', function() {
  1643. this.fitColumns(true, true);
  1644. this.updateHeaders();
  1645. this.updateHeaderSortState();
  1646. }, this, {single: true});
  1647. }
  1648. } else if (this.forceFit) {
  1649. this.fitColumns(true, false);
  1650. } else if (this.grid.autoExpandColumn) {
  1651. this.autoExpand(true);
  1652. }
  1653. this.grid.getGridEl().dom.innerHTML = this.renderUI();
  1654. this.afterRenderUI();
  1655. },
  1656. /* --------------------------------- Model Events and Handlers --------------------------------*/
  1657. /**
  1658. * @private
  1659. * Binds a new Store and ColumnModel to this GridView. Removes any listeners from the old objects (if present)
  1660. * and adds listeners to the new ones
  1661. * @param {Ext.data.Store} newStore The new Store instance
  1662. * @param {Ext.grid.ColumnModel} newColModel The new ColumnModel instance
  1663. */
  1664. initData : function(newStore, newColModel) {
  1665. var me = this;
  1666. if (me.ds) {
  1667. var oldStore = me.ds;
  1668. oldStore.un('add', me.onAdd, me);
  1669. oldStore.un('load', me.onLoad, me);
  1670. oldStore.un('clear', me.onClear, me);
  1671. oldStore.un('remove', me.onRemove, me);
  1672. oldStore.un('update', me.onUpdate, me);
  1673. oldStore.un('datachanged', me.onDataChange, me);
  1674. if (oldStore !== newStore && oldStore.autoDestroy) {
  1675. oldStore.destroy();
  1676. }
  1677. }
  1678. if (newStore) {
  1679. newStore.on({
  1680. scope : me,
  1681. load : me.onLoad,
  1682. add : me.onAdd,
  1683. remove : me.onRemove,
  1684. update : me.onUpdate,
  1685. clear : me.onClear,
  1686. datachanged: me.onDataChange
  1687. });
  1688. }
  1689. if (me.cm) {
  1690. var oldColModel = me.cm;
  1691. oldColModel.un('configchange', me.onColConfigChange, me);
  1692. oldColModel.un('widthchange', me.onColWidthChange, me);
  1693. oldColModel.un('headerchange', me.onHeaderChange, me);
  1694. oldColModel.un('hiddenchange', me.onHiddenChange, me);
  1695. oldColModel.un('columnmoved', me.onColumnMove, me);
  1696. }
  1697. if (newColModel) {
  1698. delete me.lastViewWidth;
  1699. newColModel.on({
  1700. scope : me,
  1701. configchange: me.onColConfigChange,
  1702. widthchange : me.onColWidthChange,
  1703. headerchange: me.onHeaderChange,
  1704. hiddenchange: me.onHiddenChange,
  1705. columnmoved : me.onColumnMove
  1706. });
  1707. }
  1708. me.ds = newStore;
  1709. me.cm = newColModel;
  1710. },
  1711. // private
  1712. onDataChange : function(){
  1713. this.refresh(true);
  1714. this.updateHeaderSortState();
  1715. this.syncFocusEl(0);
  1716. },
  1717. // private
  1718. onClear : function() {
  1719. this.refresh();
  1720. this.syncFocusEl(0);
  1721. },
  1722. // private
  1723. onUpdate : function(store, record) {
  1724. this.refreshRow(record);
  1725. },
  1726. // private
  1727. onAdd : function(store, records, index) {
  1728. this.insertRows(store, index, index + (records.length-1));
  1729. },
  1730. // private
  1731. onRemove : function(store, record, index, isUpdate) {
  1732. if (isUpdate !== true) {
  1733. this.fireEvent('beforerowremoved', this, index, record);
  1734. }
  1735. this.removeRow(index);
  1736. if (isUpdate !== true) {
  1737. this.processRows(index);
  1738. this.applyEmptyText();
  1739. this.fireEvent('rowremoved', this, index, record);
  1740. }
  1741. },
  1742. /**
  1743. * @private
  1744. * Called when a store is loaded, scrolls to the top row
  1745. */
  1746. onLoad : function() {
  1747. if (Ext.isGecko) {
  1748. if (!this.scrollToTopTask) {
  1749. this.scrollToTopTask = new Ext.util.DelayedTask(this.scrollToTop, this);
  1750. }
  1751. this.scrollToTopTask.delay(1);
  1752. } else {
  1753. this.scrollToTop();
  1754. }
  1755. },
  1756. // private
  1757. onColWidthChange : function(cm, col, width) {
  1758. this.updateColumnWidth(col, width);
  1759. },
  1760. // private
  1761. onHeaderChange : function(cm, col, text) {
  1762. this.updateHeaders();
  1763. },
  1764. // private
  1765. onHiddenChange : function(cm, col, hidden) {
  1766. this.updateColumnHidden(col, hidden);
  1767. },
  1768. // private
  1769. onColumnMove : function(cm, oldIndex, newIndex) {
  1770. this.indexMap = null;
  1771. this.refresh(true);
  1772. this.restoreScroll(this.getScrollState());
  1773. this.afterMove(newIndex);
  1774. this.grid.fireEvent('columnmove', oldIndex, newIndex);
  1775. },
  1776. // private
  1777. onColConfigChange : function() {
  1778. delete this.lastViewWidth;
  1779. this.indexMap = null;
  1780. this.refresh(true);
  1781. },
  1782. /* -------------------- UI Events and Handlers ------------------------------ */
  1783. // private
  1784. initUI : function(grid) {
  1785. grid.on('headerclick', this.onHeaderClick, this);
  1786. },
  1787. // private
  1788. initEvents : Ext.emptyFn,
  1789. // private
  1790. onHeaderClick : function(g, index) {
  1791. if (this.headersDisabled || !this.cm.isSortable(index)) {
  1792. return;
  1793. }
  1794. g.stopEditing(true);
  1795. g.store.sort(this.cm.getDataIndex(index));
  1796. },
  1797. /**
  1798. * @private
  1799. * Adds the hover class to a row when hovered over
  1800. */
  1801. onRowOver : function(e, target) {
  1802. var row = this.findRowIndex(target);
  1803. if (row !== false) {
  1804. this.addRowClass(row, this.rowOverCls);
  1805. }
  1806. },
  1807. /**
  1808. * @private
  1809. * Removes the hover class from a row on mouseout
  1810. */
  1811. onRowOut : function(e, target) {
  1812. var row = this.findRowIndex(target);
  1813. if (row !== false && !e.within(this.getRow(row), true)) {
  1814. this.removeRowClass(row, this.rowOverCls);
  1815. }
  1816. },
  1817. // private
  1818. onRowSelect : function(row) {
  1819. this.addRowClass(row, this.selectedRowClass);
  1820. },
  1821. // private
  1822. onRowDeselect : function(row) {
  1823. this.removeRowClass(row, this.selectedRowClass);
  1824. },
  1825. // private
  1826. onCellSelect : function(row, col) {
  1827. var cell = this.getCell(row, col);
  1828. if (cell) {
  1829. this.fly(cell).addClass('x-grid3-cell-selected');
  1830. }
  1831. },
  1832. // private
  1833. onCellDeselect : function(row, col) {
  1834. var cell = this.getCell(row, col);
  1835. if (cell) {
  1836. this.fly(cell).removeClass('x-grid3-cell-selected');
  1837. }
  1838. },
  1839. // private
  1840. handleWheel : function(e) {
  1841. e.stopPropagation();
  1842. },
  1843. /**
  1844. * @private
  1845. * Called by the SplitDragZone when a drag has been completed. Resizes the columns
  1846. */
  1847. onColumnSplitterMoved : function(cellIndex, width) {
  1848. this.userResized = true;
  1849. this.grid.colModel.setColumnWidth(cellIndex, width, true);
  1850. if (this.forceFit) {
  1851. this.fitColumns(true, false, cellIndex);
  1852. this.updateAllColumnWidths();
  1853. } else {
  1854. this.updateColumnWidth(cellIndex, width);
  1855. this.syncHeaderScroll();
  1856. }
  1857. this.grid.fireEvent('columnresize', cellIndex, width);
  1858. },
  1859. /**
  1860. * @private
  1861. * Click handler for the shared column dropdown menu, called on beforeshow. Builds the menu
  1862. * which displays the list of columns for the user to show or hide.
  1863. */
  1864. beforeColMenuShow : function() {
  1865. var colModel = this.cm,
  1866. colCount = colModel.getColumnCount(),
  1867. colMenu = this.colMenu,
  1868. i;
  1869. colMenu.removeAll();
  1870. for (i = 0; i < colCount; i++) {
  1871. if (colModel.config[i].hideable !== false) {
  1872. colMenu.add(new Ext.menu.CheckItem({
  1873. text : colModel.getColumnHeader(i),
  1874. itemId : 'col-' + colModel.getColumnId(i),
  1875. checked : !colModel.isHidden(i),
  1876. disabled : colModel.config[i].hideable === false,
  1877. hideOnClick: false
  1878. }));
  1879. }
  1880. }
  1881. },
  1882. /**
  1883. * @private
  1884. * Attached as the 'itemclick' handler to the header menu and the column show/hide submenu (if available).
  1885. * Performs sorting if the sorter buttons were clicked, otherwise hides/shows the column that was clicked.
  1886. */
  1887. handleHdMenuClick : function(item) {
  1888. var store = this.ds,
  1889. dataIndex = this.cm.getDataIndex(this.hdCtxIndex);
  1890. switch (item.getItemId()) {
  1891. case 'asc':
  1892. store.sort(dataIndex, 'ASC');
  1893. break;
  1894. case 'desc':
  1895. store.sort(dataIndex, 'DESC');
  1896. break;
  1897. default:
  1898. this.handleHdMenuClickDefault(item);
  1899. }
  1900. return true;
  1901. },
  1902. <div id="method-Ext.grid.GridView-handleHdMenuClickDefault"></div>/**
  1903. * Called by handleHdMenuClick if any button except a sort ASC/DESC button was clicked. The default implementation provides
  1904. * the column hide/show functionality based on the check state of the menu item. A different implementation can be provided
  1905. * if needed.
  1906. * @param {Ext.menu.BaseItem} item The menu item that was clicked
  1907. */
  1908. handleHdMenuClickDefault: function(item) {
  1909. var colModel = this.cm,
  1910. itemId = item.getItemId(),
  1911. index = colModel.getIndexById(itemId.substr(4));
  1912. if (index != -1) {
  1913. if (item.checked && colModel.getColumnsBy(this.isHideableColumn, this).length <= 1) {
  1914. this.onDenyColumnHide();
  1915. return;
  1916. }
  1917. colModel.setHidden(index, item.checked);
  1918. }
  1919. },
  1920. /**
  1921. * @private
  1922. * Called when a header cell is clicked - shows the menu if the click happened over a trigger button
  1923. */
  1924. handleHdDown : function(e, target) {
  1925. if (Ext.fly(target).hasClass('x-grid3-hd-btn')) {
  1926. e.stopEvent();
  1927. var colModel = this.cm,
  1928. header = this.findHeaderCell(target),
  1929. index = this.getCellIndex(header),
  1930. sortable = colModel.isSortable(index),
  1931. menu = this.hmenu,
  1932. menuItems = menu.items,
  1933. menuCls = this.headerMenuOpenCls;
  1934. this.hdCtxIndex = index;
  1935. Ext.fly(header).addClass(menuCls);
  1936. menuItems.get('asc').setDisabled(!sortable);
  1937. menuItems.get('desc').setDisabled(!sortable);
  1938. menu.on('hide', function() {
  1939. Ext.fly(header).removeClass(menuCls);
  1940. }, this, {single:true});
  1941. menu.show(target, 'tl-bl?');
  1942. }
  1943. },
  1944. /**
  1945. * @private
  1946. * Attached to the headers' mousemove event. This figures out the CSS cursor to use based on where the mouse is currently
  1947. * pointed. If the mouse is currently hovered over the extreme left or extreme right of any header cell and the cell next
  1948. * to it is resizable it is given the resize cursor, otherwise the cursor is set to an empty string.
  1949. */
  1950. handleHdMove : function(e) {
  1951. var header = this.findHeaderCell(this.activeHdRef);
  1952. if (header && !this.headersDisabled) {
  1953. var handleWidth = this.splitHandleWidth || 5,
  1954. activeRegion = this.activeHdRegion,
  1955. headerStyle = header.style,
  1956. colModel = this.cm,
  1957. cursor = '',
  1958. pageX = e.getPageX();
  1959. if (this.grid.enableColumnResize !== false) {
  1960. var activeHeaderIndex = this.activeHdIndex,
  1961. previousVisible = this.getPreviousVisible(activeHeaderIndex),
  1962. currentResizable = colModel.isResizable(activeHeaderIndex),
  1963. previousResizable = previousVisible && colModel.isResizable(previousVisible),
  1964. inLeftResizer = pageX - activeRegion.left <= handleWidth,
  1965. inRightResizer = activeRegion.right - pageX <= (!this.activeHdBtn ? handleWidth : 2);
  1966. if (inLeftResizer && previousResizable) {
  1967. cursor = Ext.isAir ? 'move' : Ext.isWebKit ? 'e-resize' : 'col-resize'; // col-resize not always supported
  1968. } else if (inRightResizer && currentResizable) {
  1969. cursor = Ext.isAir ? 'move' : Ext.isWebKit ? 'w-resize' : 'col-resize';
  1970. }
  1971. }
  1972. headerStyle.cursor = cursor;
  1973. }
  1974. },
  1975. /**
  1976. * @private
  1977. * Returns the index of the nearest currently visible header to the left of the given index.
  1978. * @param {Number} index The header index
  1979. * @return {Number/undefined} The index of the nearest visible header
  1980. */
  1981. getPreviousVisible: function(index) {
  1982. while (index > 0) {
  1983. if (!this.cm.isHidden(index - 1)) {
  1984. return index;
  1985. }
  1986. index--;
  1987. }
  1988. return undefined;
  1989. },
  1990. /**
  1991. * @private
  1992. * Tied to the header element's mouseover event - adds the over class to the header cell if the menu is not disabled
  1993. * for that cell
  1994. */
  1995. handleHdOver : function(e, target) {
  1996. var header = this.findHeaderCell(target);
  1997. if (header && !this.headersDisabled) {
  1998. var fly = this.fly(header);
  1999. this.activeHdRef = target;
  2000. this.activeHdIndex = this.getCellIndex(header);
  2001. this.activeHdRegion = fly.getRegion();
  2002. if (!this.isMenuDisabled(this.activeHdIndex, fly)) {
  2003. fly.addClass('x-grid3-hd-over');
  2004. this.activeHdBtn = fly.child('.x-grid3-hd-btn');
  2005. if (this.activeHdBtn) {
  2006. this.activeHdBtn.dom.style.height = (header.firstChild.offsetHeight - 1) + 'px';
  2007. }
  2008. }
  2009. }
  2010. },
  2011. /**
  2012. * @private
  2013. * Tied to the header element's mouseout event. Removes the hover class from the header cell
  2014. */
  2015. handleHdOut : function(e, target) {
  2016. var header = this.findHeaderCell(target);
  2017. if (header && (!Ext.isIE || !e.within(header, true))) {
  2018. this.activeHdRef = null;
  2019. this.fly(header).removeClass('x-grid3-hd-over');
  2020. header.style.cursor = '';
  2021. }
  2022. },
  2023. /**
  2024. * @private
  2025. * Used by {@link #handleHdOver} to determine whether or not to show the header menu class on cell hover
  2026. * @param {Number} cellIndex The header cell index
  2027. * @param {Ext.Element} el The cell element currently being hovered over
  2028. */
  2029. isMenuDisabled: function(cellIndex, el) {
  2030. return this.cm.isMenuDisabled(cellIndex);
  2031. },
  2032. /**
  2033. * @private
  2034. * Returns true if there are any rows rendered into the GridView
  2035. * @return {Boolean} True if any rows have been rendered
  2036. */
  2037. hasRows : function() {
  2038. var fc = this.mainBody.dom.firstChild;
  2039. return fc && fc.nodeType == 1 && fc.className != 'x-grid-empty';
  2040. },
  2041. /**
  2042. * @private
  2043. */
  2044. isHideableColumn : function(c) {
  2045. return !c.hidden;
  2046. },
  2047. /**
  2048. * @private
  2049. * DEPRECATED - will be removed in Ext JS 5.0
  2050. */
  2051. bind : function(d, c) {
  2052. this.initData(d, c);
  2053. }
  2054. });
  2055. // private
  2056. // This is a support class used internally by the Grid components
  2057. Ext.grid.GridView.SplitDragZone = Ext.extend(Ext.dd.DDProxy, {
  2058. constructor: function(grid, hd){
  2059. this.grid = grid;
  2060. this.view = grid.getView();
  2061. this.marker = this.view.resizeMarker;
  2062. this.proxy = this.view.resizeProxy;
  2063. Ext.grid.GridView.SplitDragZone.superclass.constructor.call(this, hd,
  2064. 'gridSplitters' + this.grid.getGridEl().id, {
  2065. dragElId : Ext.id(this.proxy.dom), resizeFrame:false
  2066. });
  2067. this.scroll = false;
  2068. this.hw = this.view.splitHandleWidth || 5;
  2069. },
  2070. b4StartDrag : function(x, y){
  2071. this.dragHeadersDisabled = this.view.headersDisabled;
  2072. this.view.headersDisabled = true;
  2073. var h = this.view.mainWrap.getHeight();
  2074. this.marker.setHeight(h);
  2075. this.marker.show();
  2076. this.marker.alignTo(this.view.getHeaderCell(this.cellIndex), 'tl-tl', [-2, 0]);
  2077. this.proxy.setHeight(h);
  2078. var w = this.cm.getColumnWidth(this.cellIndex),
  2079. minw = Math.max(w-this.grid.minColumnWidth, 0);
  2080. this.resetConstraints();
  2081. this.setXConstraint(minw, 1000);
  2082. this.setYConstraint(0, 0);
  2083. this.minX = x - minw;
  2084. this.maxX = x + 1000;
  2085. this.startPos = x;
  2086. Ext.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
  2087. },
  2088. allowHeaderDrag : function(e){
  2089. return true;
  2090. },
  2091. handleMouseDown : function(e){
  2092. var t = this.view.findHeaderCell(e.getTarget());
  2093. if(t && this.allowHeaderDrag(e)){
  2094. var xy = this.view.fly(t).getXY(),
  2095. x = xy[0],
  2096. exy = e.getXY(),
  2097. ex = exy[0],
  2098. w = t.offsetWidth,
  2099. adjust = false;
  2100. if((ex - x) <= this.hw){
  2101. adjust = -1;
  2102. }else if((x+w) - ex <= this.hw){
  2103. adjust = 0;
  2104. }
  2105. if(adjust !== false){
  2106. this.cm = this.grid.colModel;
  2107. var ci = this.view.getCellIndex(t);
  2108. if(adjust == -1){
  2109. if (ci + adjust < 0) {
  2110. return;
  2111. }
  2112. while(this.cm.isHidden(ci+adjust)){
  2113. --adjust;
  2114. if(ci+adjust < 0){
  2115. return;
  2116. }
  2117. }
  2118. }
  2119. this.cellIndex = ci+adjust;
  2120. this.split = t.dom;
  2121. if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
  2122. Ext.grid.GridView.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
  2123. }
  2124. }else if(this.view.columnDrag){
  2125. this.view.columnDrag.callHandleMouseDown(e);
  2126. }
  2127. }
  2128. },
  2129. endDrag : function(e){
  2130. this.marker.hide();
  2131. var v = this.view,
  2132. endX = Math.max(this.minX, e.getPageX()),
  2133. diff = endX - this.startPos,
  2134. disabled = this.dragHeadersDisabled;
  2135. v.onColumnSplitterMoved(this.cellIndex, this.cm.getColumnWidth(this.cellIndex)+diff);
  2136. setTimeout(function(){
  2137. v.headersDisabled = disabled;
  2138. }, 50);
  2139. },
  2140. autoOffset : function(){
  2141. this.setDelta(0,0);
  2142. }
  2143. });
  2144. </pre>
  2145. </body>
  2146. </html>