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.

2549 lines
95 KiB

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