@refinitiv-ui/efx-grid 6.0.2 → 6.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/lib/column-dragging/es6/ColumnDragging.d.ts +49 -0
  2. package/lib/column-dragging/es6/ColumnDragging.js +764 -0
  3. package/lib/column-dragging/es6/index.d.ts +1 -0
  4. package/lib/column-dragging/es6/index.js +1 -0
  5. package/lib/column-format-dialog/lib/column-format-dialog.d.ts +13 -1
  6. package/lib/column-selection-dialog/lib/column-selection-dialog.d.ts +15 -2
  7. package/lib/column-selection-dialog/lib/column-selection-dialog.js +146 -5
  8. package/lib/core/dist/core.css +1 -1
  9. package/lib/core/dist/core.js +468 -1092
  10. package/lib/core/dist/core.min.js +1 -1
  11. package/lib/core/es6/data/ColumnStats.d.ts +2 -2
  12. package/lib/core/es6/data/DataCache.d.ts +4 -4
  13. package/lib/core/es6/data/DataTable.d.ts +5 -5
  14. package/lib/core/es6/data/DataTable.js +33 -11
  15. package/lib/core/es6/data/DataView.d.ts +12 -18
  16. package/lib/core/es6/data/DataView.js +0 -4
  17. package/lib/core/es6/data/Segment.d.ts +2 -0
  18. package/lib/core/es6/data/Segment.js +7 -0
  19. package/lib/core/es6/data/SegmentCollection.d.ts +3 -3
  20. package/lib/core/es6/data/WrappedView.d.ts +13 -13
  21. package/lib/core/es6/data/WrappedView.js +6 -6
  22. package/lib/core/es6/grid/Core.d.ts +31 -27
  23. package/lib/core/es6/grid/Core.js +47 -11
  24. package/lib/core/es6/grid/ILayoutGrid.d.ts +15 -15
  25. package/lib/core/es6/grid/LayoutGrid.js +54 -26
  26. package/lib/core/es6/grid/VirtualizedLayoutGrid.js +71 -0
  27. package/lib/core/es6/grid/components/Cell.d.ts +4 -4
  28. package/lib/core/es6/grid/components/CellFloatingPanel.d.ts +1 -1
  29. package/lib/core/es6/grid/components/CellSpans.d.ts +8 -8
  30. package/lib/core/es6/grid/components/Column.d.ts +1 -1
  31. package/lib/core/es6/grid/components/ElementWrapper.d.ts +6 -6
  32. package/lib/core/es6/grid/components/Scrollbar.d.ts +3 -1
  33. package/lib/core/es6/grid/components/Scrollbar.js +13 -0
  34. package/lib/core/es6/grid/components/StretchedCells.js +2 -2
  35. package/lib/core/es6/grid/plugins/SortableTitlePlugin.d.ts +14 -6
  36. package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +147 -81
  37. package/lib/core/es6/grid/util/Conflator.d.ts +2 -2
  38. package/lib/core/es6/grid/util/ElementFrameWork.d.ts +3 -3
  39. package/lib/core/es6/grid/util/HttpRequest.d.ts +2 -2
  40. package/lib/core/es6/grid/util/PercentBarRenderer.d.ts +1 -1
  41. package/lib/core/es6/grid/util/RangeBar.d.ts +1 -1
  42. package/lib/core/es6/grid/util/SectionSettings.d.ts +5 -5
  43. package/lib/core/es6/grid/util/SectionSettings.js +5 -0
  44. package/lib/core/es6/grid/util/SelectionList.d.ts +2 -2
  45. package/lib/core/es6/grid/util/TrackLayout.d.ts +7 -3
  46. package/lib/core/es6/grid/util/TrackLayout.js +27 -0
  47. package/lib/core/es6/grid/util/util.d.ts +2 -2
  48. package/lib/core/es6/index.d.ts +1 -5
  49. package/lib/core/es6/index.js +1 -7
  50. package/lib/core/es6/tr-grid-theme.js +1 -1
  51. package/lib/filter-dialog/lib/checkbox-list.d.ts +13 -1
  52. package/lib/filter-dialog/lib/filter-dialog.d.ts +14 -1
  53. package/lib/filter-dialog/lib/filter-dialog.js +86 -26
  54. package/lib/filter-dialog/themes/base-checkbox.less +8 -1
  55. package/lib/filter-dialog/themes/base.less +69 -1
  56. package/lib/filter-dialog/themes/elemental/dark/checkbox-list.js +1 -1
  57. package/lib/filter-dialog/themes/elemental/dark/es5/all-elements.js +2 -2
  58. package/lib/filter-dialog/themes/elemental/dark/filter-dialog.js +1 -1
  59. package/lib/filter-dialog/themes/elemental/light/checkbox-list.js +1 -1
  60. package/lib/filter-dialog/themes/elemental/light/es5/all-elements.js +2 -2
  61. package/lib/filter-dialog/themes/elemental/light/filter-dialog.js +1 -1
  62. package/lib/filter-dialog/themes/halo/dark/checkbox-list.js +1 -1
  63. package/lib/filter-dialog/themes/halo/dark/es5/all-elements.js +2 -2
  64. package/lib/filter-dialog/themes/halo/dark/filter-dialog.js +1 -1
  65. package/lib/filter-dialog/themes/halo/light/checkbox-list.js +1 -1
  66. package/lib/filter-dialog/themes/halo/light/es5/all-elements.js +2 -2
  67. package/lib/filter-dialog/themes/halo/light/filter-dialog.js +1 -1
  68. package/lib/filter-dialog/themes/solar/charcoal/checkbox-list.js +1 -1
  69. package/lib/filter-dialog/themes/solar/charcoal/es5/all-elements.js +2 -2
  70. package/lib/filter-dialog/themes/solar/charcoal/filter-dialog.js +1 -1
  71. package/lib/filter-dialog/themes/solar/pearl/checkbox-list.js +1 -1
  72. package/lib/filter-dialog/themes/solar/pearl/es5/all-elements.js +2 -2
  73. package/lib/filter-dialog/themes/solar/pearl/filter-dialog.js +1 -1
  74. package/lib/grid/lib/efx-grid.d.ts +25 -10
  75. package/lib/grid/lib/efx-grid.js +22 -56
  76. package/lib/grid/themes/base.less +1 -1
  77. package/lib/grid/themes/halo/dark/efx-grid.js +1 -1
  78. package/lib/grid/themes/halo/dark/es5/all-elements.js +1 -1
  79. package/lib/grid/themes/halo/efx-grid.less +33 -39
  80. package/lib/grid/themes/halo/light/efx-grid.js +1 -1
  81. package/lib/grid/themes/halo/light/es5/all-elements.js +1 -1
  82. package/lib/grid/themes/solar/charcoal/efx-grid.js +1 -1
  83. package/lib/grid/themes/solar/charcoal/es5/all-elements.js +1 -1
  84. package/lib/grid/themes/solar/pearl/efx-grid.js +1 -1
  85. package/lib/grid/themes/solar/pearl/es5/all-elements.js +1 -1
  86. package/lib/index.d.ts +2 -0
  87. package/lib/index.js +2 -0
  88. package/lib/row-segmenting/es6/RowSegmenting.d.ts +7 -2
  89. package/lib/row-segmenting/es6/RowSegmenting.js +98 -11
  90. package/lib/rt-grid/dist/rt-grid.js +1244 -1249
  91. package/lib/rt-grid/dist/rt-grid.min.js +1 -1
  92. package/lib/rt-grid/es6/ColumnDefinition.d.ts +5 -3
  93. package/lib/rt-grid/es6/ColumnDefinition.js +17 -108
  94. package/lib/rt-grid/es6/DataConnector.d.ts +3 -3
  95. package/lib/rt-grid/es6/Grid.d.ts +24 -9
  96. package/lib/rt-grid/es6/Grid.js +285 -103
  97. package/lib/rt-grid/es6/RowDefSorter.d.ts +19 -0
  98. package/lib/rt-grid/es6/RowDefSorter.js +137 -0
  99. package/lib/rt-grid/es6/RowDefinition.d.ts +9 -7
  100. package/lib/rt-grid/es6/RowDefinition.js +6 -0
  101. package/lib/rt-grid/es6/SnapshotFiller.d.ts +6 -1
  102. package/lib/rt-grid/es6/SnapshotFiller.js +144 -15
  103. package/lib/tr-grid-checkbox/es6/Checkbox.d.ts +4 -3
  104. package/lib/tr-grid-checkbox/es6/Checkbox.js +51 -21
  105. package/lib/tr-grid-column-selection/es6/ColumnSelection.js +46 -9
  106. package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +8 -4
  107. package/lib/tr-grid-column-stack/es6/ColumnStack.js +240 -125
  108. package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.d.ts +4 -3
  109. package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +28 -13
  110. package/lib/tr-grid-in-cell-editing/es6/InCellEditing.d.ts +8 -5
  111. package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +106 -3
  112. package/lib/tr-grid-percent-bar/es6/PercentBar.js +1 -1
  113. package/lib/tr-grid-printer/es6/CellWriter.d.ts +3 -3
  114. package/lib/tr-grid-printer/es6/GridPrinter.d.ts +1 -1
  115. package/lib/tr-grid-printer/es6/GridPrinter.js +26 -13
  116. package/lib/tr-grid-printer/es6/PrintTrait.d.ts +2 -2
  117. package/lib/tr-grid-printer/es6/SectionWriter.d.ts +3 -3
  118. package/lib/tr-grid-row-dragging/es6/RowDragging.d.ts +3 -4
  119. package/lib/tr-grid-row-dragging/es6/RowDragging.js +86 -195
  120. package/lib/tr-grid-row-grouping/es6/RowGrouping.d.ts +7 -2
  121. package/lib/tr-grid-row-grouping/es6/RowGrouping.js +97 -7
  122. package/lib/tr-grid-row-selection/es6/RowSelection.d.ts +8 -8
  123. package/lib/tr-grid-row-selection/es6/RowSelection.js +55 -31
  124. package/lib/tr-grid-textformatting/es6/TextFormatting.d.ts +1 -1
  125. package/lib/tr-grid-textformatting/es6/TextFormatting.js +12 -0
  126. package/lib/tr-grid-util/es6/CellPainter.js +1 -1
  127. package/lib/tr-grid-util/es6/DragUI.d.ts +16 -0
  128. package/lib/tr-grid-util/es6/DragUI.js +214 -0
  129. package/lib/tr-grid-util/es6/ElementObserver.d.ts +2 -0
  130. package/lib/tr-grid-util/es6/ElementObserver.js +32 -2
  131. package/lib/tr-grid-util/es6/ElfUtil.d.ts +4 -1
  132. package/lib/tr-grid-util/es6/ElfUtil.js +131 -28
  133. package/lib/tr-grid-util/es6/ExpanderIcon.js +2 -2
  134. package/lib/tr-grid-util/es6/FieldFormatter.js +7 -5
  135. package/lib/tr-grid-util/es6/GridPlugin.js +8 -4
  136. package/lib/tr-grid-util/es6/MultiTableManager.d.ts +8 -0
  137. package/lib/tr-grid-util/es6/MultiTableManager.js +164 -57
  138. package/lib/tr-grid-util/es6/NumberFormatter.d.ts +2 -0
  139. package/lib/tr-grid-util/es6/NumberFormatter.js +64 -19
  140. package/lib/tr-grid-util/es6/RowPainter.js +57 -19
  141. package/lib/tr-grid-util/es6/formula/Formula.js +9 -1
  142. package/lib/tr-grid-util/es6/jsx.d.ts +223 -0
  143. package/lib/types/es6/Checkbox.d.ts +4 -3
  144. package/lib/types/es6/ColumnStack.d.ts +8 -4
  145. package/lib/types/es6/CompositeGrid/ColumnSelectionPlugin.d.ts +3 -2
  146. package/lib/types/es6/CompositeGrid/ColumnWidthAdjustingPlugin.d.ts +2 -1
  147. package/lib/types/es6/CompositeGrid/CompositeGrid.d.ts +20 -18
  148. package/lib/types/es6/CompositeGrid/DragAndDropTitlePlugin.d.ts +2 -1
  149. package/lib/types/es6/CompositeGrid/DraggableContentPlugin.d.ts +3 -2
  150. package/lib/types/es6/CompositeGrid/Plugin.d.ts +28 -0
  151. package/lib/types/es6/CompositeGrid/ResizableTitlePlugin.d.ts +2 -1
  152. package/lib/types/es6/CompositeGrid/RowSelectionPlugin.d.ts +5 -4
  153. package/lib/types/es6/CompositeGrid/TreeIndentingPlugin.d.ts +2 -1
  154. package/lib/types/es6/CompositeGrid/index.d.ts +9 -9
  155. package/lib/types/es6/ConditionalColoring.d.ts +4 -3
  156. package/lib/types/es6/Core/data/ColumnStats.d.ts +2 -2
  157. package/lib/types/es6/Core/data/DataCache.d.ts +4 -4
  158. package/lib/types/es6/Core/data/DataTable.d.ts +5 -5
  159. package/lib/types/es6/Core/data/DataView.d.ts +12 -18
  160. package/lib/types/es6/Core/data/Segment.d.ts +2 -0
  161. package/lib/types/es6/Core/data/SegmentCollection.d.ts +3 -3
  162. package/lib/types/es6/Core/data/WrappedView.d.ts +13 -13
  163. package/lib/types/es6/Core/grid/Core.d.ts +31 -27
  164. package/lib/types/es6/Core/grid/ILayoutGrid.d.ts +15 -15
  165. package/lib/types/es6/Core/grid/components/Cell.d.ts +4 -4
  166. package/lib/types/es6/Core/grid/components/CellFloatingPanel.d.ts +1 -1
  167. package/lib/types/es6/Core/grid/components/CellSpans.d.ts +8 -8
  168. package/lib/types/es6/Core/grid/components/Column.d.ts +1 -1
  169. package/lib/types/es6/Core/grid/components/ElementWrapper.d.ts +6 -6
  170. package/lib/types/es6/Core/grid/components/Scrollbar.d.ts +3 -1
  171. package/lib/types/es6/Core/grid/plugins/SortableTitlePlugin.d.ts +14 -6
  172. package/lib/types/es6/Core/grid/util/Conflator.d.ts +2 -2
  173. package/lib/types/es6/Core/grid/util/ElementFrameWork.d.ts +3 -3
  174. package/lib/types/es6/Core/grid/util/HttpRequest.d.ts +2 -2
  175. package/lib/types/es6/Core/grid/util/PercentBarRenderer.d.ts +1 -1
  176. package/lib/types/es6/Core/grid/util/RangeBar.d.ts +1 -1
  177. package/lib/types/es6/Core/grid/util/SectionSettings.d.ts +5 -5
  178. package/lib/types/es6/Core/grid/util/SelectionList.d.ts +2 -2
  179. package/lib/types/es6/Core/grid/util/TrackLayout.d.ts +7 -3
  180. package/lib/types/es6/Core/grid/util/util.d.ts +2 -2
  181. package/lib/types/es6/Core/index.d.ts +1 -5
  182. package/lib/types/es6/ExtensionOptions.d.ts +2 -0
  183. package/lib/types/es6/InCellEditing.d.ts +8 -5
  184. package/lib/types/es6/RealtimeGrid/ColumnDefinition.d.ts +5 -3
  185. package/lib/types/es6/RealtimeGrid/DataConnector.d.ts +3 -3
  186. package/lib/types/es6/RealtimeGrid/Grid.d.ts +24 -9
  187. package/lib/types/es6/RealtimeGrid/RowDefSorter.d.ts +19 -0
  188. package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +9 -7
  189. package/lib/types/es6/RealtimeGrid/SnapshotFiller.d.ts +6 -1
  190. package/lib/types/es6/RowDragging.d.ts +3 -4
  191. package/lib/types/es6/RowGrouping.d.ts +7 -2
  192. package/lib/types/es6/RowSegmenting.d.ts +7 -2
  193. package/lib/types/es6/RowSelection.d.ts +8 -8
  194. package/lib/types/es6/TextFormatting.d.ts +1 -1
  195. package/lib/types/es6/index.d.ts +1 -0
  196. package/lib/versions.json +17 -16
  197. package/package.json +1 -1
  198. package/lib/core/es6/grid/plugins/DragAndDropTitlePlugin.d.ts +0 -24
  199. package/lib/core/es6/grid/plugins/DragAndDropTitlePlugin.js +0 -615
  200. package/lib/core/es6/grid/plugins/Plugin.d.ts +0 -28
  201. package/lib/core/es6/grid/plugins/Plugin.js +0 -272
  202. package/lib/types/es6/Core/grid/plugins/DragAndDropTitlePlugin.d.ts +0 -24
  203. package/lib/types/es6/Core/grid/plugins/Plugin.d.ts +0 -28
@@ -2,7 +2,7 @@
2
2
  /******/ "use strict";
3
3
  var __webpack_exports__ = {};
4
4
 
5
- // UNUSED EXPORTS: Cell, CellFloatingPanel, CellSpan, CellSpans, Column, ColumnStats, Conflator, Core, DataCache, DataTable, DataView, DragAndDropTitlePlugin, ElementFrameWork, ElementWrapper, EventDispatcher, HScrollbar, ILayoutGrid, LayoutGrid, Plugin, Reverter, Scrollbar, SectionSettings, SelectionList, SortableTitlePlugin, TrackLayout, VScrollbar, VirtualizedLayoutGrid, Virtualizer, default
5
+ // UNUSED EXPORTS: Cell, CellFloatingPanel, CellSpan, CellSpans, Column, ColumnStats, Conflator, Core, DataCache, DataTable, DataView, ElementFrameWork, ElementWrapper, EventDispatcher, HScrollbar, ILayoutGrid, LayoutGrid, Reverter, Scrollbar, SectionSettings, SelectionList, SortableTitlePlugin, TrackLayout, VScrollbar, VirtualizedLayoutGrid, Virtualizer, default
6
6
 
7
7
  ;// CONCATENATED MODULE: ./src/js/grid/util/util.js
8
8
  /**
@@ -3031,6 +3031,33 @@ TrackLayout.prototype.setLaneSize = function (index, val) {
3031
3031
  return false;
3032
3032
  };
3033
3033
 
3034
+ /** @public
3035
+ * @param {number} index
3036
+ * @param {string} propName
3037
+ * @param {*} val
3038
+ * @return {boolean}
3039
+ */
3040
+ TrackLayout.prototype.setLaneProperty = function (index, propName, val) {
3041
+ if (index < 0 || index >= this._laneCount) { return false; }
3042
+
3043
+ var col = this._cols[index];
3044
+ if (col == null || col[propName] !== val) {
3045
+ col = this._newColumn(index);
3046
+ col[propName] = val;
3047
+ return true;
3048
+ }
3049
+
3050
+ return false;
3051
+ };
3052
+ /** @public
3053
+ * @param {number} index
3054
+ * @param {string} propName
3055
+ * @return {*}
3056
+ */
3057
+ TrackLayout.prototype.getLaneProperty = function (index, propName) {
3058
+ var col = this._cols[index];
3059
+ return (col && col[propName] != null) ? col[propName] : null;
3060
+ };
3034
3061
  /** @public
3035
3062
  * @param {number} index
3036
3063
  * @return {number}
@@ -5017,10 +5044,10 @@ StretchedCells.prototype.getColumnIndex = function (cellRef) {
5017
5044
  if(cellRef["getElement"]) {
5018
5045
  var cellElement = cellRef["getElement"]();
5019
5046
  if(cellElement) {
5020
- return cellElement._colIndex || 0;
5047
+ return cellElement._colIndex != null ? cellElement._colIndex : -1;
5021
5048
  }
5022
5049
  } else {
5023
- return cellRef._colIndex || 0;
5050
+ return cellRef._colIndex != null ? cellRef._colIndex : -1;
5024
5051
  }
5025
5052
  }
5026
5053
  return -1;
@@ -7503,6 +7530,19 @@ Scrollbar.prototype.freezeScrolling = function (frozen) {
7503
7530
  this._isFrozen = frozen !== false;
7504
7531
  return prev;
7505
7532
  };
7533
+ /** @public
7534
+ */
7535
+ Scrollbar.prototype.restoreTrackPosition = function () {
7536
+ // Scroll event will be fired asynchronously, if there is any change
7537
+ var track = this._element;
7538
+ if(this._vertical) {
7539
+ track.scrollTop = this._tScrollVal;
7540
+ if(track.scrollTop){
7541
+ this._tScrollVal = track.scrollTop; //Check to ensure that cache equal to element's scroll
7542
+ }
7543
+ }
7544
+ //TODO: handle restore scrollLeft for hscroll
7545
+ };
7506
7546
 
7507
7547
  Scrollbar._proto = Scrollbar.prototype;
7508
7548
 
@@ -8280,6 +8320,22 @@ LayoutGrid.prototype._setColumnWidth = function (indexX, val) {
8280
8320
  LayoutGrid.prototype._updateColumnLayout = function () {
8281
8321
  this._syncLayoutToColumns(0);
8282
8322
  };
8323
+ /** @public
8324
+ * @ignore
8325
+ * @param {boolean} enabled
8326
+ * @param {number=} fromR
8327
+ * @param {number=} toR
8328
+ */
8329
+ LayoutGrid.prototype._startBindingSession = function (enabled, fromR, toR) {
8330
+ // Prevent error when calling _startBindingSession in LayoutGrid
8331
+ };
8332
+ /** @public
8333
+ * @ignore
8334
+ * @return {Array<boolean>}
8335
+ */
8336
+ LayoutGrid.prototype._getTempRowHeights = function () {
8337
+ return null;
8338
+ };
8283
8339
 
8284
8340
  /**
8285
8341
  * {@link ILayoutGrid#getRowHeight}
@@ -9121,6 +9177,11 @@ LayoutGrid.prototype.setRowHighlight = function (rowIndex) {
9121
9177
  this._highlightedCells[c] = cell;
9122
9178
  cell.addClass("highlighted-row");
9123
9179
  }
9180
+ var stretchEl = this.getStretchedCell(rowIndex); // check stretched cell
9181
+ if(stretchEl) {
9182
+ this._highlightedCells.push(stretchEl);
9183
+ stretchEl.addClass("highlighted-row");
9184
+ }
9124
9185
  } else {
9125
9186
  this._highlightedCells.length = 0;
9126
9187
  }
@@ -9406,6 +9467,7 @@ LayoutGrid.prototype.insertColumn = function (index, opt_json) {
9406
9467
  cell.addClass("selected-row");
9407
9468
  }
9408
9469
  }
9470
+ // TODO: Check if it can insert column with stretch cell
9409
9471
  }
9410
9472
 
9411
9473
  column.activate(atTheMiddle || !this._colVir);
@@ -9637,6 +9699,10 @@ LayoutGrid.prototype.stretchCell = function (cellRef, rowIndex, opt_stretching,
9637
9699
  } else {
9638
9700
  cell = this._stretchedCells.unstretchCell(rowIndex);
9639
9701
  }
9702
+ if(cell) {
9703
+ var selected = this._selectionList.getSelection(rowIndex);
9704
+ cell.enableClass("selected-row", selected); // It's can enable class without get stretch cell again.
9705
+ }
9640
9706
  return cell;
9641
9707
  };
9642
9708
 
@@ -9719,6 +9785,19 @@ LayoutGrid.prototype._calculateViewSize = function (forceRecal) {
9719
9785
  }
9720
9786
  return stretchSize;
9721
9787
  };
9788
+
9789
+ /**
9790
+ * @private
9791
+ * @param {number} rowIndex
9792
+ * @param {string} className
9793
+ * @param {boolean} enabled
9794
+ */
9795
+ LayoutGrid.prototype._enableStretchCellClass = function (rowIndex, className, enabled ) {
9796
+ var stretchEl = this.getStretchedCell(rowIndex); // check stretched cell
9797
+ if(stretchEl) {
9798
+ stretchEl.enableClass(className, enabled);
9799
+ }
9800
+ };
9722
9801
  /** View size is width of container (Grid's pane) or content (LayoutGrid's columns), whichever is smaller.
9723
9802
  * @public
9724
9803
  * @ignore
@@ -10402,11 +10481,16 @@ LayoutGrid.prototype._updateCellSpans = function (cellSpans, adding) {
10402
10481
  */
10403
10482
  LayoutGrid.prototype._onMouseMove = function (e) {
10404
10483
  var target = e["target"];
10405
- var colElement = util.closestElement(target, "column");
10406
- var colIndex = this.getColumnIndex(colElement);
10407
- var cellElement = (colIndex >= 0) ? util.closestElement(target, "cell") : null;
10408
10484
 
10409
- this.setRowHighlight(this.getCellIndex(colIndex, cellElement));
10485
+ var cellElement = util.closestElement(target, "cell");
10486
+ var colIndex = this._stretchedCells.getColumnIndex(cellElement);
10487
+ if(colIndex < 0) { // Not found colIndex in stretching cell, then get from normal row
10488
+ var colElement = util.closestElement(target, "column");
10489
+ colIndex = this.getColumnIndex(colElement);
10490
+ }
10491
+ var rowIndex = this.getCellIndex(colIndex, cellElement);
10492
+
10493
+ this.setRowHighlight(rowIndex);
10410
10494
  };
10411
10495
 
10412
10496
  /**
@@ -10437,27 +10521,16 @@ LayoutGrid.prototype._onMouseOut = function (e) {
10437
10521
  */
10438
10522
  LayoutGrid.prototype._updateSelectionUI = function (rowIndex) { // Update UI of the specified row index
10439
10523
  var selected = this._selectionList.getSelection(rowIndex);
10440
-
10441
- for (var c = 0; c < this._colCount; ++c) {
10442
- var cell = this._columns[c].getCell(rowIndex);
10443
-
10444
- if (cell) {
10445
- cell.enableClass("selected-row", selected);
10446
- }
10447
- }
10524
+ this._enableStretchCellClass(rowIndex, "selected-row", selected);
10525
+ this.enableRowClass(rowIndex, "selected-row", selected);
10448
10526
  };
10449
10527
 
10450
10528
  /** @private
10451
10529
  * @param {number} rowIndex
10452
10530
  */
10453
10531
  LayoutGrid.prototype._addSelectionUI = function (rowIndex) {
10454
- for (var c = 0; c < this._colCount; ++c) {
10455
- var cell = this._columns[c].getCell(rowIndex);
10456
-
10457
- if (cell) {
10458
- cell.addClass("selected-row");
10459
- }
10460
- }
10532
+ this._enableStretchCellClass(rowIndex, "selected-row", true);
10533
+ this.enableRowClass(rowIndex, "selected-row", true);
10461
10534
  };
10462
10535
 
10463
10536
  /**
@@ -10465,13 +10538,8 @@ LayoutGrid.prototype._addSelectionUI = function (rowIndex) {
10465
10538
  * @param {number} rowIndex
10466
10539
  */
10467
10540
  LayoutGrid.prototype._removeSelectionUI = function (rowIndex) {
10468
- for (var c = 0; c < this._colCount; ++c) {
10469
- var cell = this._columns[c].getCell(rowIndex);
10470
-
10471
- if (cell) {
10472
- cell.removeClass("selected-row");
10473
- }
10474
- }
10541
+ this._enableStretchCellClass(rowIndex, "selected-row", false);
10542
+ this.enableRowClass(rowIndex, "selected-row", false);
10475
10543
  };
10476
10544
 
10477
10545
  /**
@@ -11981,6 +12049,13 @@ Segment.prototype.removeAllChildren = function(objMap) {
11981
12049
  Segment.prototype.getChildIds = function() {
11982
12050
  return this._childCount ? Object.keys(this._children) : [];
11983
12051
  };
12052
+ /** @public
12053
+ * @return {number}
12054
+ */
12055
+ Segment.prototype.getChildCount = function() {
12056
+ return this._childCount;
12057
+ };
12058
+
11984
12059
 
11985
12060
 
11986
12061
  /** @public
@@ -13319,7 +13394,7 @@ DataTable.prototype.setColumnSortingLogic = function(cid, func) {
13319
13394
  * @example
13320
13395
  * var prevState = dt.freeze();
13321
13396
  * for(var i = 0; i < 100; ++i) {
13322
- * dt.insertRow({}); // no event is fired
13397
+ * dt.insertRow(); // no event is fired
13323
13398
  * }
13324
13399
  * dt.freeze(prevState); // Restore previous freeze states
13325
13400
  */
@@ -13356,6 +13431,7 @@ DataTable.prototype.isFrozen = function() {
13356
13431
  */
13357
13432
  DataTable.prototype.setSegmentSeparator = function(rid, enabled) {
13358
13433
  var change = false;
13434
+ var memberCount = 0;
13359
13435
  if(typeof rid === "string") {
13360
13436
  if(enabled !== false) {
13361
13437
  if(!this._segments) {
@@ -13365,16 +13441,20 @@ DataTable.prototype.setSegmentSeparator = function(rid, enabled) {
13365
13441
  change = true;
13366
13442
  }
13367
13443
  } else if(this._segments) {
13368
- if(this._segments.removeSegment(rid)) {
13369
- change = true;
13370
- if(!this._segments.getSegmentCount()) {
13371
- this._segments = null;
13444
+ var segment = this._segments.getSegment(rid);
13445
+ if(segment) {
13446
+ memberCount = segment.getChildCount();
13447
+ if(this._segments.removeSegment(rid)) {
13448
+ change = true;
13449
+ if(!this._segments.getSegmentCount()) {
13450
+ this._segments = null;
13451
+ }
13372
13452
  }
13373
13453
  }
13374
13454
  }
13375
13455
  }
13376
13456
  if(change && this._needFiring()) {
13377
- if(this._autoFillSegments()) {
13457
+ if(this._autoFillSegments() || memberCount) {
13378
13458
  this.dispatchGlobalChange();
13379
13459
  } else {
13380
13460
  var rowData = this._rows[rid] || null;
@@ -13486,13 +13566,14 @@ DataTable.prototype._autoFillSegments = function() {
13486
13566
  }
13487
13567
  return false;
13488
13568
  };
13489
- /** Remove existing segment children and fill the segments with all contnet rows before the next segment separator
13569
+ /** Remove existing segment children and fill the segments with all content rows before the next segment separator
13490
13570
  * @public
13491
13571
  * @param {string} segmentId Row id
13492
13572
  */
13493
13573
  DataTable.prototype.fillSegment = function(segmentId) {
13494
13574
  if(this._segments) {
13495
13575
  this._segments.fillSegment(segmentId, this._rids);
13576
+ this.dispatchGlobalChange();
13496
13577
  }
13497
13578
  };
13498
13579
  /** Remove all existing segment children in each segment and fill the segments with all contnet rows before the next segment separator
@@ -13501,7 +13582,11 @@ DataTable.prototype.fillSegment = function(segmentId) {
13501
13582
  */
13502
13583
  DataTable.prototype.fillSegments = function() {
13503
13584
  if(this._segments) {
13504
- return this._segments.fillSegments(this._rids);
13585
+ var dirty = this._segments.fillSegments(this._rids);
13586
+ if(dirty) {
13587
+ this.dispatchGlobalChange();
13588
+ }
13589
+ return dirty;
13505
13590
  }
13506
13591
  return false;
13507
13592
  };
@@ -13546,7 +13631,11 @@ DataTable.prototype.addSegmentChildren = function(segmentId, rids) {
13546
13631
  */
13547
13632
  DataTable.prototype.removeSegmentChild = function(segmentId, rid) {
13548
13633
  if(this._segments) {
13549
- return this._segments.removeSegmentChild(segmentId, rid);
13634
+ var dirty = this._segments.removeSegmentChild(segmentId, rid);
13635
+ if(dirty) {
13636
+ this.dispatchGlobalChange();
13637
+ }
13638
+ return dirty;
13550
13639
  }
13551
13640
  return false;
13552
13641
  };
@@ -13557,7 +13646,11 @@ DataTable.prototype.removeSegmentChild = function(segmentId, rid) {
13557
13646
  */
13558
13647
  DataTable.prototype.removeSegmentChildren = function(segmentId, rids) {
13559
13648
  if(this._segments) {
13560
- return this._segments.removeSegmentChildren(segmentId, rids);
13649
+ var dirty = this._segments.removeSegmentChildren(segmentId, rids);
13650
+ if(dirty) {
13651
+ this.dispatchGlobalChange();
13652
+ }
13653
+ return dirty;
13561
13654
  }
13562
13655
  return false;
13563
13656
  };
@@ -13566,7 +13659,11 @@ DataTable.prototype.removeSegmentChildren = function(segmentId, rids) {
13566
13659
  */
13567
13660
  DataTable.prototype.removeAllSegmentChildren = function() {
13568
13661
  if(this._segments) {
13569
- return this._segments.removeAllSegmentChildren();
13662
+ var dirty = this._segments.removeAllSegmentChildren();
13663
+ if (dirty) {
13664
+ this.dispatchGlobalChange();
13665
+ }
13666
+ return dirty;
13570
13667
  }
13571
13668
  return false;
13572
13669
  };
@@ -15523,7 +15620,7 @@ WrappedView.prototype.addRowExpansion = function(rid, count) {
15523
15620
  * @param {string} rid Row Id
15524
15621
  */
15525
15622
  WrappedView.prototype.removeRowExpansion = function(rid) {
15526
- this._dv.removeRowExpansion(rid, count);
15623
+ this._dv.removeRowExpansion(rid);
15527
15624
  };
15528
15625
  /**
15529
15626
  * @public
@@ -15730,7 +15827,7 @@ WrappedView.prototype.setSegmentCollapsingLogic = function() {};
15730
15827
  */
15731
15828
  WrappedView.prototype.isSegmentCollapsed = function(rowRef) {
15732
15829
  var rid = this._toRowId(rowRef);
15733
- return this._dv.isSegmentCollapsed(rid, collapsed);
15830
+ return this._dv.isSegmentCollapsed(rid);
15734
15831
  };
15735
15832
  /** Remove existing segment children and fill the segments with all contnet rows before the next segment separator
15736
15833
  * @public
@@ -15763,8 +15860,8 @@ WrappedView.prototype.addSegmentChild = function(segmentRef, rowRef) {
15763
15860
  */
15764
15861
  WrappedView.prototype.addSegmentChildren = function(segmentRef, rowRefs) {
15765
15862
  var segmentId = this._toRowId(segmentRef);
15766
- var rowId = this._toRowId(rowRef);
15767
- return this._dv.addSegmentChildren(segmentId, rowId);
15863
+ var rowIds = this._toRowIds(rowRefs);
15864
+ return this._dv.addSegmentChildren(segmentId, rowIds);
15768
15865
  };
15769
15866
  /** @public
15770
15867
  * @param {string|number} segmentRef Row id or row index
@@ -15783,8 +15880,8 @@ WrappedView.prototype.removeSegmentChild = function(segmentRef, rowRef) {
15783
15880
  */
15784
15881
  WrappedView.prototype.removeSegmentChildren = function(segmentRef, rowRefs) {
15785
15882
  var segmentId = this._toRowId(segmentRef);
15786
- var rowId = this._toRowId(rowRef);
15787
- return this._dv.removeSegmentChildren(segmentId, rowId);
15883
+ var rowIds = this._toRowIds(rowRefs);
15884
+ return this._dv.removeSegmentChildren(segmentId, rowIds);
15788
15885
  };
15789
15886
  /** @public
15790
15887
  * @return {boolean} Return true if there is any change
@@ -16088,10 +16185,6 @@ Conflator.prototype.enable = function (opt_enabled) {
16088
16185
 
16089
16186
 
16090
16187
 
16091
- /** @typedef {DataTable|WrappedView|DataView} DataView~IDataView
16092
- * @description DataView like classes
16093
- */
16094
-
16095
16188
  /** @event DataView#dataChanged
16096
16189
  * @description Trigger when data within the data view has been changed. Not only actual change in data, but also position change will trigger this event.
16097
16190
  * @property {boolean} globalChange Indicates a big change. User should expect all data has been change. With active sorting or filtering, this flag will always be true due to multiple changes in row position.
@@ -20589,6 +20682,11 @@ SectionSettings.prototype._dispatchDataChanged = function (firstUpdate, lastUpda
20589
20682
  */
20590
20683
  SectionSettings.prototype.updateRowData = function (fromRowIndex, lastRowIndex, e) {
20591
20684
  if(this.isDataBindable()) { // Prevent dispatching dataChanged event without the data view
20685
+ if(this._grid._getTempRowHeights()){
20686
+ fromRowIndex = this._grid.getFirstIndexInView();
20687
+ lastRowIndex = this._grid.getLastIndexInView() + 1;
20688
+ }
20689
+
20592
20690
  e = this.extendDataEventArg(e, fromRowIndex, lastRowIndex);
20593
20691
  if(e["fromRowIndex"] < e["toRowIndex"]) {
20594
20692
  this._dispatch("dataChanged", e);
@@ -21283,6 +21381,11 @@ es6_Ext.inherits(VirtualizedLayoutGrid, components_ElementWrapper);
21283
21381
  */
21284
21382
  VirtualizedLayoutGrid.prototype._index = -1;
21285
21383
 
21384
+ /** Number of rows offsetting from the first section
21385
+ * @private
21386
+ * @type {number}
21387
+ */
21388
+ VirtualizedLayoutGrid.prototype._rowOffset = 0;
21286
21389
  /** For virtualization in Y-Axis
21287
21390
  * @private
21288
21391
  * @type {number}
@@ -21344,6 +21447,14 @@ VirtualizedLayoutGrid.prototype._boundLayer = null;
21344
21447
  * @private
21345
21448
  */
21346
21449
  VirtualizedLayoutGrid.prototype._hscrollbar = null;
21450
+ /** @type {string}
21451
+ * @private
21452
+ */
21453
+ VirtualizedLayoutGrid.prototype._session = "A";
21454
+ /** @type {Array<boolean>}
21455
+ * @private
21456
+ */
21457
+ VirtualizedLayoutGrid.prototype._tempRowHeights = null;
21347
21458
 
21348
21459
  //#region ====== Override ElementWrapper ======//
21349
21460
  /** @override */
@@ -21455,13 +21566,68 @@ VirtualizedLayoutGrid.prototype._setColumnWidth = function (indexX, val) {
21455
21566
  VirtualizedLayoutGrid.prototype._updateColumnLayout = function () {
21456
21567
  this._grid._updateColumnLayout();
21457
21568
  };
21569
+ /** @public
21570
+ * @ignore
21571
+ * @param {boolean} enabled
21572
+ */
21573
+ VirtualizedLayoutGrid.prototype._startBindingSession = function (enabled) {
21574
+ this._isBinding = enabled;
21575
+ if(!enabled){
21576
+ // Clear old session
21577
+ if(this._tempRowHeights){
21578
+ var defaultRowHeight = this.getDefaultRowHeight();
21579
+ var hasSession = true;
21580
+ var removedIndices = [];
21581
+
21582
+ for(var key in this._tempRowHeights){
21583
+ var index = +key;
21584
+ var rowSession = this._layoutY.getLaneProperty(index, "sizeSession");
21585
+ if(rowSession) {
21586
+ if(rowSession != this._session){
21587
+ this.setRowHeight(index, defaultRowHeight);
21588
+ this._layoutY.setLaneProperty(index, "sizeSession", null);
21589
+ removedIndices.push(index);
21590
+ }
21591
+ }
21592
+ }
21593
+ var removedCount = removedIndices.length;
21594
+ for(var i = 0; i < removedCount; i++){
21595
+ delete this._tempRowHeights[removedIndices[i]];
21596
+ }
21597
+ if(removedCount){
21598
+ for(var remainingKey in this._tempRowHeights){
21599
+ hasSession = remainingKey != null;
21600
+ break;
21601
+ }
21602
+ }
21603
+ if(!hasSession){
21604
+ this._tempRowHeights = null;
21605
+ }
21458
21606
 
21607
+ }
21608
+ this._session = this._session === "A" ? "B" : "A";
21609
+ }
21610
+ };
21611
+ /** @public
21612
+ * @ignore
21613
+ * @return {Array<boolean>}
21614
+ */
21615
+ VirtualizedLayoutGrid.prototype._getTempRowHeights = function () {
21616
+ return this._tempRowHeights;
21617
+ };
21459
21618
  /** @inheritDoc */
21460
21619
  VirtualizedLayoutGrid.prototype.getRowHeight = function (index) {
21461
21620
  return this._layoutY.getLaneSize(index);
21462
21621
  };
21463
21622
  /** @inheritDoc */
21464
21623
  VirtualizedLayoutGrid.prototype.setRowHeight = function (index, val) {
21624
+ if(this._isBinding && val != this.getDefaultRowHeight()){
21625
+ this._layoutY.setLaneProperty(index, "sizeSession", this._session);
21626
+ if(!this._tempRowHeights){
21627
+ this._tempRowHeights = [];
21628
+ }
21629
+ this._tempRowHeights[index] = true; // Store row index that set temporary row height
21630
+ }
21465
21631
  if(this._layoutY.setLaneSize(index, val)) {
21466
21632
  this._grid.setRowHeight(index - this._firstIndex, val);
21467
21633
  this._element.style.height = this._layoutY.getTrackSize() + "px";
@@ -21615,6 +21781,9 @@ VirtualizedLayoutGrid.prototype.setRowCount = function (val, noBinding) {
21615
21781
  var prevCount = this._layoutY.getLaneCount();
21616
21782
  if(prevCount !== val){
21617
21783
  this._layoutY.setLaneCount(val);
21784
+ if(this._tempRowHeights){
21785
+ this._tempRowHeights.length = val;
21786
+ }
21618
21787
  this._element.style.height = this._layoutY.getTrackSize() + "px";
21619
21788
  this._requestUpdatingRowBounds();
21620
21789
  //After rowCountChanged fires, virtualizer will update virtual row count if
@@ -22503,6 +22672,7 @@ var Core_Core = function (opt_initializer) {
22503
22672
  _t._updateColumnBounds = _t._updateColumnBounds.bind(_t);
22504
22673
  _t._dispatchColumnPositionChanged = _t._dispatchColumnPositionChanged.bind(_t);
22505
22674
  _t._dispatchRowPositionChanged = _t._dispatchRowPositionChanged.bind(_t);
22675
+ _t._requestScrollbarUpdate = _t._requestScrollbarUpdate.bind(_t);
22506
22676
 
22507
22677
  // Text nodes are unintentionally getting in the tag.
22508
22678
  if(opt_initializer) { // Any node other than element node is not allowed within the tag.
@@ -22920,6 +23090,10 @@ Core_Core.prototype._preserveProportion = false;
22920
23090
  * @private
22921
23091
  */
22922
23092
  Core_Core.prototype._preserveGridSize = false;
23093
+ /** @type {number}
23094
+ * @private
23095
+ */
23096
+ Core_Core.prototype._rowHeightTimerId = 0;
22923
23097
  //#region Public Methods
22924
23098
 
22925
23099
  /**
@@ -22927,7 +23101,7 @@ Core_Core.prototype._preserveGridSize = false;
22927
23101
  * @return {string}
22928
23102
  */
22929
23103
  Core_Core.getVersion = function () {
22930
- return "5.0.50";
23104
+ return "5.0.59";
22931
23105
  };
22932
23106
  /** {@link ElementWrapper#dispose}
22933
23107
  * @override
@@ -23246,6 +23420,10 @@ Core_Core.prototype.addSectionAt = function (at, opt_type, opt_sectionName) {
23246
23420
  }
23247
23421
 
23248
23422
  this._updateSectionIndices(at);
23423
+ if (this._autoSetDataSource) {
23424
+ // This could trigger data binding and column virtualization
23425
+ sectionSettings.setDataSource(this._dataSource);
23426
+ }
23249
23427
 
23250
23428
  sectType = sectionSettings.getType();
23251
23429
  if (sectType === "footer") {
@@ -25751,6 +25929,11 @@ Core_Core.prototype.getScrollHeight = function () {
25751
25929
  }
25752
25930
  return this._vscrollbar.getContentHeight();
25753
25931
  };
25932
+ /** @public
25933
+ */
25934
+ Core_Core.prototype.restoreScrollbars = function () {
25935
+ this._vscrollbar.restoreTrackPosition();
25936
+ };
25754
25937
 
25755
25938
  /** @public
25756
25939
  * @ignore
@@ -25876,6 +26059,13 @@ Core_Core.prototype.requestRowRefresh = function() {
25876
26059
  this._rowRefreshTimer = setTimeout(this._onRowRefresh, 100);
25877
26060
  }
25878
26061
  };
26062
+ /** Set a timer to call updateScrollbarHeight only once to avoid performance issue due to multiple call of _updateScrollbarHeight()
26063
+ * @public
26064
+ */
26065
+ Core_Core.prototype._requestScrollbarUpdate = function() {
26066
+ this._updateScrollbarHeight(true, true);
26067
+ this._rowHeightTimerId = 0;
26068
+ };
25879
26069
 
25880
26070
  /** prevent bind data process
25881
26071
  * @public
@@ -26468,9 +26658,6 @@ Core_Core.prototype._newSection = function (opt_type, sectionName) {
26468
26658
  section.listen("rowCountChanged", this._onRowCountChanged);
26469
26659
  section.listen("rowHeightChanged", this._onRowHeightChanged);
26470
26660
 
26471
- if (this._autoSetDataSource) {
26472
- sectionSettings.setDataSource(this._dataSource);
26473
- }
26474
26661
  return sectionSettings;
26475
26662
  };
26476
26663
 
@@ -26761,7 +26948,12 @@ Core_Core.prototype._removeColumn = function (num) { // TODO: change the logic
26761
26948
  */
26762
26949
  Core_Core.prototype._onSectionDataChanged = function (e) {
26763
26950
  if(this._dispatchingDataChanged) { return; } // Prevent infinite loop
26764
- this._dispatchingDataChanged = true;
26951
+
26952
+ var colCount = this._layoutX.getLaneCount();
26953
+ this._dispatchingDataChanged = colCount ? true : false;
26954
+ if(!colCount) {
26955
+ return;
26956
+ }
26765
26957
 
26766
26958
  var fromR = /** @type{number} */(e["fromRowIndex"]);
26767
26959
  var toR = /** @type{number} */(e["toRowIndex"]);
@@ -26769,6 +26961,9 @@ Core_Core.prototype._onSectionDataChanged = function (e) {
26769
26961
  var dataView = /** @type{DataView} */(e["dataSource"]);
26770
26962
  var hasDataView = (dataView && dataView.getDataSource()) ? 1 : 0;
26771
26963
  var rids, rowDataCollection;
26964
+
26965
+ section._startBindingSession(true);
26966
+
26772
26967
  if(hasDataView) {
26773
26968
  rids = dataView.getVisibleRowIds(true);
26774
26969
  rowDataCollection = dataView.getMultipleRowData(rids, fromR, toR);
@@ -26776,7 +26971,6 @@ Core_Core.prototype._onSectionDataChanged = function (e) {
26776
26971
  }
26777
26972
  this._dispatch("preSectionDataBinding", e);
26778
26973
 
26779
- var colCount = this._layoutX.getLaneCount();
26780
26974
  var dataMap = this.getDataColumnMap();
26781
26975
  for (var c = 0; c < colCount; ++c) {
26782
26976
  if(section["isColumnActive"](c) && (this.isColumnVisible(c) || this._isAlwaysRenderColumn(c))) {
@@ -26807,8 +27001,9 @@ Core_Core.prototype._onSectionDataChanged = function (e) {
26807
27001
  }
26808
27002
 
26809
27003
  this._dispatch("postSectionDataBinding", e);
26810
-
26811
27004
  this._dispatchRowExpansionBinding(e);
27005
+
27006
+ section._startBindingSession(false);
26812
27007
  this._dispatchingDataChanged = false;
26813
27008
  };
26814
27009
 
@@ -26882,6 +27077,9 @@ Core_Core.prototype._onRowInViewChanged = function (e) { // Triggered from virtu
26882
27077
  * @param {Object} e
26883
27078
  */
26884
27079
  Core_Core.prototype._onColInViewChanged = function (e) {
27080
+ if(!this.getColumnCount()) {
27081
+ return; // No column for activation and no cell to be rendered
27082
+ }
26885
27083
  var pfi = e["prevFirstIndex"];
26886
27084
  var pli = e["prevLastIndex"]; // INCLUSIVE
26887
27085
  var fi = e["firstIndex"];
@@ -27131,8 +27329,14 @@ Core_Core.prototype._onRowHeightChanged = function (e) {
27131
27329
  this._rowHeightConflator._needScrollbarUpdate = false;
27132
27330
  this._updateScrollbarHeight(true, true);
27133
27331
  } else if(minSectionIndex >= 0) {
27134
- this._updateScrollbarHeight(minSectionIndex < this._startVScrollbarIndex,
27135
- minSectionIndex >= this._startVScrollbarIndex);
27332
+ if(this._dispatchingDataChanged){
27333
+ if(!this._rowHeightTimerId){
27334
+ this._rowHeightTimerId = setTimeout(this._requestScrollbarUpdate, 0);
27335
+ }
27336
+ } else {
27337
+ this._updateScrollbarHeight(minSectionIndex < this._startVScrollbarIndex,
27338
+ minSectionIndex >= this._startVScrollbarIndex);
27339
+ }
27136
27340
  }
27137
27341
 
27138
27342
  this._dispatchRowPositionChanged();
@@ -27197,7 +27401,7 @@ Core_Core.prototype._onColumnCountChanged = function () {
27197
27401
  // TODO: Optimize these methods during initialization
27198
27402
  var pinnedLeft = this._countPinnedLeftColumns();
27199
27403
  var pinnedRight = this._countPinnedRightColumns();
27200
- ///
27404
+
27201
27405
  this._updateColumnBounds();
27202
27406
 
27203
27407
  if (this._hScrollbarEnabled && pinnedLeft + pinnedRight < this.getColumnCount()) {
@@ -27558,7 +27762,8 @@ Core_Core.prototype._updateSectionIndices = function (from) {
27558
27762
 
27559
27763
  /** @private */
27560
27764
  Core_Core.prototype._updateLayout = function () {
27561
- if(this._disposed) { return; }
27765
+ var element = this.getElement();
27766
+ if(this._disposed || !element.offsetParent) { return; }
27562
27767
 
27563
27768
  this._syncLayoutToColumns(); // Update only if need
27564
27769
 
@@ -27588,976 +27793,85 @@ Core_Core._proto = Core_Core.prototype;
27588
27793
  /* harmony default export */ const grid_Core = (Core_Core);
27589
27794
 
27590
27795
 
27591
- ;// CONCATENATED MODULE: ./src/js/grid/plugins/Plugin.js
27796
+ ;// CONCATENATED MODULE: ./src/js/grid/plugins/SortableTitlePlugin.js
27797
+ /* eslint-disable */
27592
27798
 
27593
27799
 
27594
- // eslint-disable-line
27595
27800
 
27596
- // eslint-disable-line
27597
27801
 
27598
27802
 
27599
- /** Base class for all built-in plugins
27600
- * @constructor
27601
- * @extends {EventDispatcher}
27602
- */
27603
- var Plugin = function () {
27604
- /* throw("Plugin is an abstract Class"); */
27605
- };
27606
- es6_Ext.inherits(Plugin, event_EventDispatcher); // Inherits() will replace prototype of the derived object
27607
27803
 
27608
- //#region Public Methods
27609
- /**The name must be readonly and unique among all other plugins
27610
- * @public
27611
- * @return {string}
27612
- */
27613
- Plugin.prototype.getName = function () {
27614
- return "Plugin";
27615
- };
27804
+ /* eslint-enable */
27616
27805
 
27617
- /** @public
27618
- * @param {!Core} owner
27806
+ /** Fired when user click and before the sorting operation.
27807
+ * @event SortableTitlePlugin#preClicked
27808
+ * @property {number} colIndex
27809
+ * @property {Element} target Element being clicked
27810
+ * @example
27811
+ * function onPreClicked(e) {
27812
+ * e.cancel = true; // Cancel sorting operation
27813
+ * }
27619
27814
  */
27620
- Plugin.prototype.initialize = function (owner) {
27621
- this._host = owner;
27622
- };
27623
- /**For disposing any resource
27624
- * @public
27625
- * @param {!Core} owner
27815
+
27816
+ /** Fired when user click and after the sorting operation
27817
+ * @event SortableTitlePlugin#clicked
27818
+ * @property {number} colIndex
27819
+ * @property {string} sortOrder "a" for "ascending, "d" for descending, and "n" for none
27820
+ * @property {string} dataColumnName Field that is used for sorting
27626
27821
  */
27627
- Plugin.prototype.unload = function (owner) {
27628
- this._host = null;
27629
- this.unlistenAll();
27630
- };
27631
27822
 
27632
- /** @public
27633
- * @param {Event|Element|ElementWrapper} e
27634
- * @return {Core}
27823
+ /** Fired just before sorting data. This allows additional modification before the actual sorting
27824
+ * @event SortableTitlePlugin#preDataSorting
27825
+ * @property {boolean=} isUserAction This has true value, if event initiate from clicking title/header section
27635
27826
  */
27636
- Plugin.prototype.getRelativeGrid = function (e) {
27637
- var targetEl;
27638
- if(e.target) { // The Given object is an Event
27639
- targetEl = /** @type{Element} */(e.target);
27640
- var gridAPI = targetEl["api"];
27641
- if(gridAPI && gridAPI["getCoreGrid"]) {
27642
- return /** @type{Core} */(gridAPI["getCoreGrid"]());
27643
- }
27644
- } else if(e["getElement"]) { // The Given object is implementing ElementWrapper
27645
- targetEl = e["getElement"]();
27646
- } else if(util.isElement(e)){ // The Given object is just an element
27647
- targetEl = /** @type{Element} */(e);
27648
- }
27649
27827
 
27650
- var gridEl = (targetEl) ? util.closestElement(targetEl, "tr-grid") : null;
27651
- if(gridEl) {
27652
- if(this._host) {
27653
- if(this._host.getElement() === gridEl) {
27654
- return this._host;
27655
- }
27656
- } else {
27657
- var hostLength = this._hosts ? this._hosts.length : 0;
27658
- for (var i = 0; i < hostLength; i++) {
27659
- var host = this._hosts[i];
27660
- if (host.getElement() === gridEl) {
27661
- return host;
27662
- }
27663
- }
27664
- }
27665
- }
27828
+ /** Fired once column is sorted and before {@link SortableTitlePlugin#clicked}
27829
+ * @event SortableTitlePlugin#columnSorted
27830
+ * @property {number} colIndex
27831
+ * @property {string} sortOrder "a" for "ascending, "d" for descending, and "n" for none
27832
+ * @property {string} sortedField Field that is used for sorting
27833
+ * @property {Array.<number>} colIndices An array of colIndex
27834
+ * @property {Array.<string>} sortOrders An array of sortOrder
27835
+ * @property {Array.<string>} sortedFields An array of sortedField
27836
+ */
27666
27837
 
27667
- return null;
27668
- };
27669
- /** Use in case of there is an overlay over the top of the grid (target element cannot be used).
27670
- * @public
27671
- * @param {number} x
27672
- * @param {number} y
27673
- * @return {Element}
27838
+ /** @constructor
27839
+ * @extends {EventDispatcher}
27840
+ * @param {SortableTitlePlugin.Options=} options
27674
27841
  */
27675
- Plugin.prototype.getGridElementFromPoint = function (x, y) {
27676
- var elem = document.elementFromPoint(x, y);
27677
- var grid = util.closestElement(elem, "tr-grid");
27842
+ var SortableTitlePlugin = function (options) { // TODO: Extract SortableTitlePlugin to grid extension.
27843
+ var _t = this;
27844
+ _t._onSectionAdded = _t._onSectionAdded.bind(_t);
27845
+ _t._onMouseDown = _t._onMouseDown.bind(_t);
27678
27846
 
27679
- // Some elements are over grid element, hide them all by setting the visibility to hidden
27680
- var skipElem = [];
27681
- var skipVisibility = [];
27682
- while (!grid && elem && elem.tagName != "HTML") {
27683
- skipElem.push(elem);
27684
- skipVisibility.push(elem.style.visibility);
27685
- elem.style.visibility = "hidden";
27686
- elem = document.elementFromPoint(x, y);
27847
+ _t._onUIUpdated = _t._onUIUpdated.bind(_t);
27687
27848
 
27688
- grid = util.closestElement(elem, "tr-grid");
27689
- }
27690
- for (var i = 0; i < skipElem.length; i++) {
27691
- skipElem[i].style.visibility = skipVisibility[i];
27692
- }
27693
- return grid;
27694
- };
27849
+ _t._onColumnAdded = _t._onColumnAdded.bind(_t);
27850
+ _t._onColumnRemoved = _t._onColumnRemoved.bind(_t);
27851
+ _t._onItemSortingClicked = _t._onItemSortingClicked.bind(_t);
27852
+ _t.refresh = _t.refresh.bind(_t);
27695
27853
 
27696
- //#endregion Public Methods
27854
+ _t._hosts = [];
27855
+ _t._sortLogic = {};
27697
27856
 
27698
- //#region Protected Methods
27699
- /** @protected
27700
- * @ignore
27701
- * @return {Array.<string>}
27702
- */
27703
- Plugin.prototype._getDataColumnMap = function () {
27704
- if (this._dataMap) { return this._dataMap; }
27857
+ _t._addEvents(
27858
+ "preClicked"
27859
+ , "clicked"
27860
+ , "preDataSorting"
27861
+ , "columnSorted"
27862
+ );
27705
27863
 
27706
- if (this._host) {
27707
- return this._host.getDataColumnMap();
27708
- }
27709
- if (this._hosts && this._hosts[0]) {
27710
- return this._hosts[0].getDataColumnMap();
27864
+ _t._sortStates = [];
27865
+ _t._sortingSequence = ["a", "d"];
27866
+
27867
+ if(options) {
27868
+ _t.config({ "sorting": options });
27711
27869
  }
27712
- return null;
27713
27870
  };
27714
- /** @protected
27715
- * @ignore
27716
- * @param {number} colIndex
27717
- * @return {string}
27718
- */
27719
- Plugin.prototype._getDataColumnName = function (colIndex) {
27720
- var dataMap = this._getDataColumnMap();
27721
- if(dataMap){
27722
- return dataMap[colIndex] || "";
27723
- }
27724
- return "";
27725
- };
27726
-
27727
- /** @protected
27728
- * @ignore
27729
- * @param {Object} e
27730
- * @return {boolean}
27731
- */
27732
- Plugin.prototype._isNotFirstHost = function(e) {
27733
- if (this._hosts) {
27734
- return e["sender"] !== this._hosts[0];
27735
- }
27736
- return false;
27737
- };
27738
- /** @protected
27739
- * @ignore
27740
- * @param {Object} e
27741
- */
27742
- Plugin.prototype._onColumnAdded = function (e) {
27743
- if (this._isNotFirstHost(e)) {
27744
- return;
27745
- }
27746
- if (!e["atTheMiddle"]) { return; }
27747
- var colIndex = /** @type{number} */(e["colIndex"]);
27748
- util.insertArrayItem(this._colData, colIndex, null);
27749
- util.insertArrayItem(this._dataMap, colIndex, null);
27750
- };
27751
- /** @protected
27752
- * @ignore
27753
- * @param {Object} e
27754
- */
27755
- Plugin.prototype._onColumnMoved = function (e) {
27756
- if (this._isNotFirstHost(e)) {
27757
- return;
27758
- }
27759
- var from = /** @type{number} */(e["fromColIndex"]);
27760
- var to = /** @type{number} */(e["toColIndex"]);
27761
-
27762
- util.moveArrayItem(this._colData, from, to);
27763
- util.moveArrayItem(this._dataMap, from, to);
27764
- };
27765
- /** @protected
27766
- * @ignore
27767
- * @param {Object} e
27768
- */
27769
- Plugin.prototype._onColumnRemoved = function (e) {
27770
- if (this._isNotFirstHost(e)) {
27771
- return;
27772
- }
27773
- if (!e["atTheMiddle"]) { return; }
27774
- var colIndex = /** @type{number} */(e["colIndex"]);
27775
- if(this._colData) {
27776
- this._colData.splice(colIndex, 1);
27777
- }
27778
- if(this._dataMap) {
27779
- this._dataMap.splice(colIndex, 1);
27780
- }
27781
- };
27782
-
27783
-
27784
- /** @protected
27785
- * @ignore
27786
- * @return {number}
27787
- */
27788
- Plugin.prototype._getColumnCount = function() {
27789
- var host = this._host || this._hosts[0];
27790
- return (host) ? host.getColumnCount() : 0;
27791
- };
27792
- /** @protected
27793
- * @ignore
27794
- * @param {string} pluginName
27795
- * @return {*|null}
27796
- */
27797
- Plugin.prototype._getPlugin = function(pluginName) {
27798
- var host = this._host || this._hosts[0];
27799
- return (host) ? host.getPlugin(pluginName) : null;
27800
- };
27801
-
27802
- /** @protected
27803
- * @ignore
27804
- * @param {number} scrollVal
27805
- */
27806
- Plugin.prototype._scrollDown = function (scrollVal) {
27807
- var host = this._host || this._hosts[0];
27808
- host.scrollDown(scrollVal);
27809
- };
27810
- /** @protected
27811
- * @ignore
27812
- * @param {number} rowIndex
27813
- */
27814
- Plugin.prototype._scrollToRow = function (rowIndex) {
27815
- var host = this._host || this._hosts[0];
27816
- host.scrollToRow(null, rowIndex);
27817
- };
27818
- /** @protected
27819
- * @ignore
27820
- * @param {number} scrollVal
27821
- */
27822
- Plugin.prototype._scrollRight = function (scrollVal) {
27823
- if(this._host) {
27824
- this._host.scrollRight(scrollVal);
27825
- } else if(this._hosts) {
27826
- var len = this._hosts.length;
27827
- for(var i = 0; i < len; ++i) {
27828
- var host = this._hosts[i];
27829
- host.scrollRight(scrollVal);
27830
- }
27831
- }
27832
- };
27833
-
27834
- //#endregion Protected Methods
27835
-
27836
- //#region Protected Fields
27837
- /** @protected
27838
- * @ignore
27839
- * @type {Core}
27840
- */
27841
- Plugin.prototype._host = null;
27842
- /** @protected
27843
- * @ignore
27844
- * @type {Array.<Core>}
27845
- */
27846
- Plugin.prototype._hosts = null; // For a plug-in that support multi-table
27847
-
27848
- /** @protected
27849
- * @ignore
27850
- * @type {Array.<string|null>}
27851
- */
27852
- Plugin.prototype._dataMap = null;
27853
- /** @protected
27854
- * @ignore
27855
- * @type {Array.<Object>}
27856
- */
27857
- Plugin.prototype._colData = null;
27858
- //#endregion Protected Fields
27859
-
27860
- Plugin._proto = Plugin.prototype;
27861
-
27862
- /* harmony default export */ const plugins_Plugin = (Plugin);
27863
-
27864
-
27865
- ;// CONCATENATED MODULE: ./src/js/grid/plugins/DragAndDropTitlePlugin.js
27866
- /* eslint-disable */
27867
-
27868
-
27869
-
27870
-
27871
-
27872
- /* eslint-enable */
27873
-
27874
- /** Event
27875
- * @event DragAndDropTitlePlugin#dragged
27876
- * @type {MouseEvent}
27877
- * @property {*} * Depends on the browser's mouse event arguments
27878
- */
27879
- /** Event
27880
- * @event DragAndDropTitlePlugin#columnMoved
27881
- * @property {number} startColumnIndex
27882
- * @property {number} destColumnIndex
27883
- */
27884
-
27885
- /** @constructor
27886
- * @extends {Plugin}
27887
- */
27888
- var DragAndDropTitlePlugin = function () {
27889
- var _t = this;
27890
-
27891
- _t._onColumnAdded = _t._onColumnAdded.bind(_t);
27892
- _t._onColumnMoved = _t._onColumnMoved.bind(_t);
27893
- _t._onColumnRemoved = _t._onColumnRemoved.bind(_t);
27894
-
27895
- _t._onMouseUp = _t._onMouseUp.bind(_t);
27896
- _t._onMouseDown = _t._onMouseDown.bind(_t);
27897
-
27898
- _t._onDrag = _t._onDrag.bind(_t);
27899
- _t._onDragStart = _t._onDragStart.bind(_t);
27900
- _t._onDragEnd = _t._onDragEnd.bind(_t);
27901
- _t._onDragPulse = _t._onDragPulse.bind(_t);
27902
-
27903
- _t._hosts = [];
27904
-
27905
- _t._guideline = document.createElement("svg");
27906
- _t._guideline.className = "tr-guideline";
27907
- _t._dragbox = document.createElement("svg");
27908
- _t._dragbox.className = "tr-dragbox";
27909
-
27910
- _t._addEvent("dragged"); // drag
27911
- _t._addEvent("dragStart");
27912
- _t._addEvent("dragInterval");
27913
- _t._addEvent("preColumnMoved");
27914
- _t._addEvent("columnMoved");
27915
-
27916
- };
27917
- es6_Ext.inherits(DragAndDropTitlePlugin, plugins_Plugin);
27918
-
27919
-
27920
- /** @private
27921
- * @type {Core}
27922
- */
27923
- DragAndDropTitlePlugin.prototype._clickedGrid;
27924
- /** @private
27925
- * @type {ILayoutGrid}
27926
- */
27927
- DragAndDropTitlePlugin.prototype._clickedSection = null;
27928
- /** @private
27929
- * @type {number}
27930
- */
27931
- DragAndDropTitlePlugin.prototype._clickedRow = -1;
27932
- /** @private
27933
- * @type {!Element}
27934
- */
27935
- DragAndDropTitlePlugin.prototype._guideline;
27936
- /** @private
27937
- * @type {!Element}
27938
- */
27939
- DragAndDropTitlePlugin.prototype._dragbox;
27940
- /** @private
27941
- * @type {number}
27942
- */
27943
- DragAndDropTitlePlugin.prototype._timerId = 0;
27944
- /** @private
27945
- * @type {number}
27946
- */
27947
- DragAndDropTitlePlugin.prototype._dragPulseId = 0;
27948
- /** @private
27949
- * @type {Object}
27950
- */
27951
- DragAndDropTitlePlugin.prototype._pos = null; // Cache of current mouse position
27952
- /** @private
27953
- * @type {number}
27954
- */
27955
- DragAndDropTitlePlugin.prototype._cacheLeft = 0;
27956
- /** @private
27957
- * @type {number}
27958
- */
27959
- DragAndDropTitlePlugin.prototype._cacheWidth = 0;
27960
-
27961
- /** @private
27962
- * @type {number}
27963
- */
27964
- DragAndDropTitlePlugin.prototype._startColumn = -1;
27965
- /** @private
27966
- * @type {number}
27967
- */
27968
- DragAndDropTitlePlugin.prototype._endColumn = -1;
27969
- /** @private
27970
- * @type {number}
27971
- */
27972
- DragAndDropTitlePlugin.prototype._destColumn = -1;
27973
- /** @private
27974
- * @type {number}
27975
- */
27976
- DragAndDropTitlePlugin.prototype._leftMovableBorder = -1;
27977
- /** @private
27978
- * @type {number}
27979
- */
27980
- DragAndDropTitlePlugin.prototype._rightMovableBorder = -1;
27981
- /** @private
27982
- * @type {boolean}
27983
- */
27984
- DragAndDropTitlePlugin.prototype._isDragging = false;
27985
- /** @private
27986
- * @type {boolean}
27987
- */
27988
- DragAndDropTitlePlugin.prototype._lockFrozen = false;
27989
- /** @private
27990
- * @type {boolean}
27991
- */
27992
- DragAndDropTitlePlugin.prototype._disabled = false;
27993
- /** @private
27994
- * @type {boolean}
27995
- */
27996
- DragAndDropTitlePlugin.prototype._noColumnMoving = false;
27997
- /** @private
27998
- * @type {boolean}
27999
- */
28000
- DragAndDropTitlePlugin.prototype._noDragBox = false;
28001
-
28002
-
28003
- /** @override */
28004
- DragAndDropTitlePlugin.prototype.getName = function () {
28005
- return "DragAndDropTitlePlugin"; // Read Only
28006
- };
28007
- /** @override */
28008
- DragAndDropTitlePlugin.prototype.initialize = function (host) {
28009
- if(this._hosts.indexOf(host) >= 0) { return; }
28010
-
28011
- this._hosts.push(host);
28012
- host.listen("mousedown", this._onMouseDown);
28013
- host.listen("columnAdded", this._onColumnAdded);
28014
- host.listen("columnMoved", this._onColumnMoved);
28015
- host.listen("columnRemoved", this._onColumnRemoved);
28016
-
28017
- host.listen("dragstart", util._preventDefault);
28018
- };
28019
-
28020
- /** @override */
28021
- DragAndDropTitlePlugin.prototype.unload = function (host) {
28022
- var at = this._hosts.indexOf(host);
28023
- if(at < 0) { return; }
28024
-
28025
- this._hosts.splice(at, 1);
28026
- host.unlisten("mousedown", this._onMouseDown);
28027
- host.unlisten("columnAdded", this._onColumnAdded);
28028
- host.unlisten("columnMoved", this._onColumnMoved);
28029
- host.unlisten("columnRemoved", this._onColumnRemoved);
28030
- };
28031
-
28032
- /** Specify column to be processed by this plugin
28033
- * @public
28034
- * @return {null}
28035
- */
28036
- DragAndDropTitlePlugin.prototype.getMarker = function () {
28037
- return null;
28038
- };
28039
-
28040
- /**
28041
- * Lock moving of frozen column. If true is spsecified, dragging is disabled for frozen column.
28042
- * @public
28043
- * @param {boolean} lock
28044
- */
28045
- DragAndDropTitlePlugin.prototype.lockFrozenColumn = function(lock) {
28046
- this._lockFrozen = lock;
28047
- };
28048
-
28049
- /** Disable this plugin entirely
28050
- * @public
28051
- * @param {boolean=} opt_disabled
28052
- */
28053
- DragAndDropTitlePlugin.prototype.disable = function(opt_disabled) {
28054
- this._disabled = opt_disabled !== false;
28055
- };
28056
- /** Disable column moving. Only cursor is showing and events are fired. No real column moving.
28057
- * @public
28058
- * @param {boolean=} opt_disabled
28059
- */
28060
- DragAndDropTitlePlugin.prototype.disableMoving = function(opt_disabled) {
28061
- this._noColumnMoving = opt_disabled !== false;
28062
- };
28063
- /** Disable column moving. Only cursor is showing and events are fired. No real column moving.
28064
- * @public
28065
- * @param {boolean=} opt_disabled
28066
- */
28067
- DragAndDropTitlePlugin.prototype.disableDragBox = function(opt_disabled) {
28068
- this._noDragBox = opt_disabled !== false;
28069
- };
28070
-
28071
- /** @private
28072
- * @param {number} colIndex
28073
- * @return {boolean}
28074
- */
28075
- DragAndDropTitlePlugin.prototype._isAllowed = function(colIndex) {
28076
- var host = this._clickedGrid || this._hosts[0];
28077
- if (host) {
28078
- var stationaryIndex = host.getStationaryColumnIndex();
28079
- if (stationaryIndex < 0) {
28080
- return true;
28081
- }
28082
- if (colIndex <= stationaryIndex) {
28083
- return false;
28084
- }
28085
- }
28086
- return true;
28087
- };
28088
- /** @private
28089
- * @param {Event} e
28090
- */
28091
- DragAndDropTitlePlugin.prototype._onMouseDown = function (e) {
28092
- if(this._disabled) {
28093
- return;
28094
- }
28095
- if(e.shiftKey || e.ctrlKey || e.altKey) {
28096
- return; // Ignore mousedown event, if modifier key is detected
28097
- }
28098
- if(e.button) {
28099
- return; // We don't allow drag with middle click (button == 1), or right click (button == 2)
28100
- }
28101
- if(this._timerId) {
28102
- return; // Drag timer is already start
28103
- }
28104
-
28105
- var host = this.getRelativeGrid(e);
28106
- if(!host) {
28107
- return; // Given event should be within grid element
28108
- }
28109
-
28110
- this._pos = host.getRelativePosition(e);
28111
- if (this._pos["hit"] === false) {
28112
- return; // Only start dragging when mouse is down on the grid
28113
- }
28114
-
28115
- var section = /** @type{ILayoutGrid} */(this._pos["section"]);
28116
- if(!section) {
28117
- return; // The section that is not in the target section list cannot be dragged
28118
- } else if(this._pos["sectionType"] !== "title") {
28119
- return; // Sections other than title section cannot be dragged by default
28120
- }
28121
-
28122
- var colIndex = this._pos["colIndex"];
28123
- if(!this._isAllowed(colIndex)) {
28124
- return; // The column cannot be dragged
28125
- }
28126
- if(this._lockFrozen && host.isPinnedColumn(colIndex)) {
28127
- return; // If the lock frag is on, frozen columns cannot be dragged
28128
- }
28129
-
28130
- var rowIndex = this._pos["rowIndex"]; // rowIndex may not exist
28131
- var movableBorder = this._findMoveableBorder(colIndex, rowIndex - 1, section);
28132
- var movingColumns = this._getSpan(colIndex, rowIndex, section);
28133
-
28134
- this._clickedGrid = host;
28135
- this._clickedSection = section;
28136
- this._clickedRow = rowIndex;
28137
-
28138
- this._startColumn = movingColumns["left"];
28139
- this._endColumn = movingColumns["right"];
28140
- this._leftMovableBorder = movableBorder["left"];
28141
- this._rightMovableBorder = movableBorder["right"];
28142
- this._destColumn = this._startColumn;
28143
-
28144
- this._timerId = setTimeout(this._onDragStart, 300);
28145
- window.addEventListener("mouseup", this._onMouseUp, false);
28146
- };
28147
- /** @private
28148
- * @param {Object} e
28149
- */
28150
- DragAndDropTitlePlugin.prototype._onMouseUp = function (e) {
28151
- if(this._timerId) {
28152
- window.clearTimeout(this._timerId);
28153
- window.removeEventListener("mouseup", this._onMouseUp, false);
28154
- this._timerId = 0;
28155
- this._clearCache();
28156
- }
28157
- };
28158
-
28159
- /** @private
28160
- */
28161
- DragAndDropTitlePlugin.prototype._onDragStart = function () {
28162
- if(this._disabled || this._isDragging) { return; }
28163
-
28164
- if (this._hasListener("dragStart")) {
28165
- this._dispatch("dragStart", /** @type{!Object} */(this._pos));
28166
- }
28167
-
28168
- if (this._pos["cancel"]) {
28169
- return;
28170
- }
28171
-
28172
- this._timerId = 0;
28173
- window.removeEventListener("mouseup", this._onMouseUp, false);
28174
-
28175
- if(!this._clickedGrid) {
28176
- return;
28177
- }
28178
-
28179
- this._isDragging = true;
28180
- document.body.classList.add("tr-dragging"); // Prevent text selection
28181
- // document.body.classList.add("tr-move-cursor");
28182
-
28183
- window.addEventListener("mousemove", this._onDrag, false);
28184
- window.addEventListener("mouseup", this._onDragEnd, true);
28185
-
28186
- var host = this._clickedGrid;
28187
- var height = host.getHeight();
28188
- var sectionBound = this._clickedSection.getBoundingClientRect();
28189
- var clickedCellBound = this._clickedSection.getCell(this._startColumn, this._clickedRow).getBoundingClientRect();
28190
-
28191
- var gridElem = host.getElement();
28192
- this._guideline.style.top = (clickedCellBound.top - sectionBound.top) + "px";
28193
- this._guideline.style.height = (height - 1) + "px";
28194
- this._dragbox.style.height = (height - 33) + "px"; // WARNING: Height could be long
28195
- this._dragbox.style.width = this._clickedSection.getColumnWidth(this._startColumn) + "px";
28196
-
28197
- // TODO: guideline and drag box should be outside of grid area
28198
- gridElem.appendChild(this._guideline);
28199
-
28200
- this._dimCol(true);
28201
- this._renderGuideline();
28202
-
28203
- // For step scrolling // TODO: Merge this logic with DraggableContentPlugin
28204
- this._scrollStep = Math.floor(host.getScrollWidth() / 25); // Update the scrollbar first
28205
- if(this._scrollStep < 40) {
28206
- this._scrollStep = 40;
28207
- } else if(this._scrollStep > 400) {
28208
- this._scrollStep = 400;
28209
- }
28210
- var scrollbar = host.getHScrollbar();
28211
- this._cacheLeft = scrollbar.getLeft() + 20;
28212
- this._cacheWidth = scrollbar.getLeft() + scrollbar.getWidth() - 20;
28213
-
28214
- this._dragPulseId = window.setInterval(this._onDragPulse, 150); // Start pulse
28215
- };
28216
- /** @private
28217
- * @param {Event} e
28218
- */
28219
- DragAndDropTitlePlugin.prototype._onDrag = function (e) {
28220
- if(!this._isDragging) { return; }
28221
-
28222
- util._preventDefault(e);
28223
- this._pos = this._clickedGrid.getRelativePosition(e); // Relative to the clicked grid
28224
-
28225
- var host = this.getRelativeGrid(e);
28226
- if (!host || host !== this._clickedGrid) { return; }
28227
-
28228
- var colIndex = this._pos["colIndex"];
28229
- if ((colIndex >= this._leftMovableBorder) &&
28230
- (colIndex <= this._rightMovableBorder) &&
28231
- this._isAllowed(colIndex) &&
28232
- !(this._lockFrozen && host.isPinnedColumn(colIndex))) {
28233
- this._renderGuideline();
28234
- this._dispatch("dragged", /** @type{!Object} */(e));
28235
- }
28236
- this._renderDragBox(e);
28237
- };
28238
- /** @private
28239
- * @param {Event} e
28240
- */
28241
- DragAndDropTitlePlugin.prototype._onDragEnd = function (e) {
28242
- if(!this._isDragging) {
28243
- return;
28244
- }
28245
-
28246
- this._isDragging = false;
28247
- document.body.classList.remove("tr-dragging");
28248
- // document.body.classList.remove("tr-move-cursor");
28249
- this._dimCol(false);
28250
-
28251
- var pn = this._guideline.parentNode;
28252
- if(pn) {
28253
- pn.removeChild(this._guideline);
28254
- }
28255
-
28256
- pn = this._dragbox.parentNode;
28257
- if(pn) {
28258
- pn.removeChild(this._dragbox);
28259
- }
28260
-
28261
- window.removeEventListener("mousemove", this._onDrag, false);
28262
- window.removeEventListener("mouseup", this._onDragEnd, true);
28263
-
28264
- if(this._dragPulseId) {
28265
- window.clearInterval(this._dragPulseId);
28266
- this._dragPulseId = 0;
28267
- }
28268
- this._pos = null;
28269
-
28270
- util._preventDefault(e);
28271
-
28272
- //When move to the right, the first position is the current one.
28273
- if (this._destColumn > this._startColumn) {
28274
- --this._destColumn;
28275
- }
28276
- //Cancel moving if the destination column is the current column or not allowed column
28277
- if ((!this._destColumn && this._destColumn !== 0) || // undefined, NaN, null
28278
- this._destColumn < 0 ||
28279
- !this._isAllowed(this._destColumn) ||
28280
- (this._destColumn >= this._startColumn && this._destColumn <= this._endColumn)) {
28281
- this._clearCache();
28282
- return;
28283
- }
28284
-
28285
- var arg = {
28286
- "startColumnIndex": this._startColumn,
28287
- "destColumnIndex": this._destColumn
28288
- };
28289
-
28290
- if (this._hasListener("preColumnMoved")) {
28291
- this._dispatch("preColumnMoved", arg);
28292
- }
28293
-
28294
- if (arg["cancel"]) {
28295
- return;
28296
- }
28297
-
28298
- if (!this._noColumnMoving) {
28299
- var shiftStart = -1;
28300
- var shiftEnd = -1;
28301
- var moveSize = -1;
28302
- if (this._startColumn > this._destColumn) { //Move backward
28303
- shiftStart = this._destColumn;
28304
- shiftEnd = this._startColumn - 1;
28305
- moveSize = -1 * (this._startColumn - this._destColumn); //Move to the left
28306
- } else
28307
- if (this._startColumn < this._destColumn) { //Move foward
28308
- shiftStart = this._endColumn + 1;
28309
- shiftEnd = this._destColumn;
28310
- moveSize = ((shiftEnd - shiftStart) + 1); //Move to the right
28311
- }
28312
-
28313
- //Perform moving all columns in the range
28314
- for(var j = this._hosts.length; --j >= 0;) {
28315
- var host = this._hosts[j];
28316
- var i;
28317
- if (moveSize > 0) { //Move forward
28318
- for (i = this._startColumn; i <= this._endColumn; i++) {
28319
- host.moveColumn(this._startColumn, this._destColumn);
28320
- }
28321
- } else { //Move backward
28322
- for (i = this._startColumn; i <= this._endColumn; i++) {
28323
- host.moveColumn(this._startColumn + (i - this._startColumn), this._destColumn + (i - this._startColumn));
28324
- }
28325
- }
28326
- }
28327
- }
28328
-
28329
- if (this._hasListener("columnMoved")) {
28330
- this._dispatch("columnMoved", {
28331
- "startColumnIndex": this._startColumn,
28332
- "endColumnIndex": this._endColumn,
28333
- "destColumnIndex": this._destColumn,
28334
- "clickedRow": this._clickedRow
28335
- });
28336
- }
28337
- this._clearCache();
28338
- };
28339
-
28340
- /** @private
28341
- */
28342
- DragAndDropTitlePlugin.prototype._onDragPulse = function() {
28343
- if(!this._isDragging || !this._pos) { return; }
28344
-
28345
- this._dispatch("dragInterval", /** @type{!Object} */(this._pos));
28346
-
28347
- var host = this._clickedGrid;
28348
- if(!host || !host.getHScrollbar().isActive()) { return; }
28349
-
28350
- var x = this._pos["x"];
28351
- var scrollVal = 0;
28352
- if(x < this._cacheLeft) {
28353
- scrollVal = -Math.floor(this._scrollStep * (0.8 + Math.random()));
28354
-
28355
- } else if(x > this._cacheWidth) {
28356
- scrollVal = Math.floor(this._scrollStep * (0.8 + Math.random()));
28357
- }
28358
-
28359
- this._scrollRight(scrollVal);
28360
- };
28361
- /** @private
28362
- */
28363
- DragAndDropTitlePlugin.prototype._clearCache = function() {
28364
- this._startColumn = this._endColumn = this._destColumn = -1;
28365
-
28366
- this._leftMovableBorder = this._rightMovableBorder = -1;
28367
-
28368
- this._clickedRow = -1;
28369
- this._clickedSection = this._clickedGrid = null;
28370
- };
28371
-
28372
- /** @private
28373
- * @param {number} colIndex
28374
- * @param {number} row
28375
- * @param {ILayoutGrid} section
28376
- * @return {!Object}
28377
- */
28378
- DragAndDropTitlePlugin.prototype._getSpan = function(colIndex, row, section) {
28379
- var cellSpan = section.getCellColSpan(colIndex, row);
28380
-
28381
- if (cellSpan <= 0) { // The specified cell is being occupied
28382
- colIndex += cellSpan; // Convert the given negative index to the spanning cell
28383
- cellSpan = section.getCellColSpan(colIndex, row);
28384
- }
28385
-
28386
- return { "left": colIndex, "right": (colIndex + cellSpan - 1) };
28387
- };
28388
- /** @private
28389
- * @param {number} col
28390
- * @param {number} row
28391
- * @param {ILayoutGrid} section
28392
- * @return {!Object}
28393
- */
28394
- DragAndDropTitlePlugin.prototype._findMoveableBorder = function(col, row, section) {
28395
- if (row < 0 || (!row && row !== 0)) { // Guaranteed to get out of infinite loop by checking undefined, NaN, null
28396
- return { "left": 0, "right": (section.getColumnCount() - 1) };
28397
- }
28398
- var span = this._getSpan(col, row, section);
28399
- if (span["right"] >= span["left"]) {
28400
- return span;
28401
- } else {
28402
- return this._findMoveableBorder(col, row - 1, section);
28403
- }
28404
- };
28405
- /**
28406
- * @private
28407
- */
28408
- DragAndDropTitlePlugin.prototype._renderGuideline = function() {
28409
- var colIndex = this._pos["colIndex"];
28410
- if(colIndex == null || colIndex < 0) { // undefined, null or negative number
28411
- return;
28412
- }
28413
-
28414
- var currentSpan = this._getSpan(colIndex, this._clickedRow, this._clickedSection);
28415
- var colStart = currentSpan["left"]; // This can be different from colIndex
28416
- var colEnd = currentSpan["right"];
28417
- var colLeft = this._clickedGrid.getColumnLeft(colStart);
28418
- var colWidth = 0;
28419
- for(var i = colStart; i <= colEnd; ++i) {
28420
- colWidth += this._clickedGrid.getColumnWidth(i);
28421
- }
28422
-
28423
- var rightHand = this._pos["x"] > colLeft + colWidth / 2;
28424
- var destColumn = (rightHand) ? colEnd + 1 : colStart;
28425
-
28426
- colLeft = this._clickedGrid.getColumnLeft(this._destColumn);
28427
- // If destination exceeds the specified bounds
28428
- if (destColumn < this._leftMovableBorder) {
28429
- destColumn = this._leftMovableBorder;
28430
- } else if (destColumn > this._rightMovableBorder) {
28431
- destColumn = this._rightMovableBorder + 1;
28432
- if(rightHand) {
28433
- colLeft -= 4; // Shift guideline to the left if this is the rightmost column
28434
- }
28435
- }
28436
-
28437
- this._destColumn = destColumn;
28438
- this._guideline.style.left = colLeft + "px";
28439
- };
28440
- /** @private
28441
- * @param {!Element|Event|MouseEvent} e
28442
- */
28443
- DragAndDropTitlePlugin.prototype._renderDragBox = function(e) {
28444
- if(this._noDragBox) {
28445
- return;
28446
- }
28447
-
28448
- var gridElem = this._clickedGrid.getElement();
28449
- var pn = this._dragbox.parentNode;
28450
- if(!pn) {
28451
- gridElem.appendChild(this._dragbox);
28452
- }
28453
-
28454
- var gridRect = gridElem.getBoundingClientRect();
28455
- var zoomFactor = this._clickedGrid["zoomFactor"]; // TODO: Remove zoom factor
28456
- var contentWidth = gridRect.width;
28457
-
28458
- var x = e.clientX - gridRect.left;
28459
- var y = ((e.pageY - gridRect.top) / zoomFactor) - window.scrollY;
28460
- var midFactor = parseFloat((x / contentWidth).toFixed(2));
28461
- var dragboxLeft = (gridRect.width * midFactor) / zoomFactor - this._dragbox.offsetWidth * midFactor;
28462
-
28463
- this._dragbox.style.left = dragboxLeft + "px";
28464
- this._dragbox.style.top = (y + 10) + "px";
28465
- };
28466
-
28467
- /**
28468
- * @private
28469
- * @param {boolean} inOut
28470
- */
28471
- DragAndDropTitlePlugin.prototype._dimCol = function(inOut) {
28472
- for (var i = this._startColumn; i <= this._endColumn; i++) {
28473
- this._clickedGrid.enableColumnClass(i, "drag-fadeout", inOut);
28474
- }
28475
- };
28476
-
28477
- DragAndDropTitlePlugin._proto = DragAndDropTitlePlugin.prototype;
28478
-
28479
- /* harmony default export */ const plugins_DragAndDropTitlePlugin = (DragAndDropTitlePlugin);
28480
-
28481
-
28482
- ;// CONCATENATED MODULE: ./src/js/grid/plugins/SortableTitlePlugin.js
28483
- /* eslint-disable */
28484
-
28485
-
28486
-
28487
-
28488
-
28489
-
28490
- /* eslint-enable */
28491
-
28492
- /** Fired when user click and before the sorting operation.
28493
- * @event SortableTitlePlugin#preClicked
28494
- * @property {number} colIndex
28495
- * @property {Element} target Element being clicked
28496
- * @example
28497
- * function onPreClicked(e) {
28498
- * e.cancel = true; // Cancel sorting operation
28499
- * }
28500
- */
28501
-
28502
- /** Fired when user click and after the sorting operation
28503
- * @event SortableTitlePlugin#clicked
28504
- * @property {number} colIndex
28505
- * @property {string} sortOrder "a" for "ascending, "d" for descending, and "n" for none
28506
- * @property {string} dataColumnName Field that is used for sorting
28507
- */
28508
-
28509
- /** Fired just before sorting data. This allows additional modification before the actual sorting
28510
- * @event SortableTitlePlugin#preDataSorting
28511
- * @property {boolean=} isUserAction This has true value, if event initiate from clicking title/header section
28512
- */
28513
-
28514
- /** Fired once column is sorted and before {@link SortableTitlePlugin#clicked}
28515
- * @event SortableTitlePlugin#columnSorted
28516
- * @property {number} colIndex
28517
- * @property {string} sortOrder "a" for "ascending, "d" for descending, and "n" for none
28518
- * @property {string} sortedField Field that is used for sorting
28519
- * @property {Array.<number>} colIndices An array of colIndex
28520
- * @property {Array.<string>} sortOrders An array of sortOrder
28521
- * @property {Array.<string>} sortedFields An array of sortedField
28522
- */
28523
-
28524
- /** @constructor
28525
- * @extends {Plugin}
28526
- * @param {SortableTitlePlugin.Options=} options
28527
- */
28528
- var SortableTitlePlugin = function (options) { // TODO: Extract SortableTitlePlugin to grid extension.
28529
- var _t = this;
28530
- _t._onSectionAdded = _t._onSectionAdded.bind(_t);
28531
- _t._onMouseDown = _t._onMouseDown.bind(_t);
28532
-
28533
- _t._onUIUpdated = _t._onUIUpdated.bind(_t);
28534
-
28535
- _t._onColumnAdded = _t._onColumnAdded.bind(_t);
28536
- _t._onColumnRemoved = _t._onColumnRemoved.bind(_t);
28537
- _t._onItemSortingClicked = _t._onItemSortingClicked.bind(_t);
28538
- _t.refresh = _t.refresh.bind(_t);
28539
-
28540
- _t._hosts = [];
28541
- _t._sortLogic = {};
28542
-
28543
- _t._addEvents(
28544
- "preClicked"
28545
- , "clicked"
28546
- , "preDataSorting"
28547
- , "columnSorted"
28548
- );
28549
-
28550
- _t._sortStates = [];
28551
- _t._sortingSequence = ["a", "d"];
28552
-
28553
- if(options) {
28554
- _t.config({ "sorting": options });
28555
- }
28556
- };
28557
- es6_Ext.inherits(SortableTitlePlugin, plugins_Plugin);
28558
-
28559
- /**
28560
- * @typedef {"a" | "ascending" | "d" | "descending" | "n" | null} SortableTitlePlugin~SortOrder
27871
+ es6_Ext.inherits(SortableTitlePlugin, event_EventDispatcher);
27872
+
27873
+ /**
27874
+ * @typedef {"a" | "ascending" | "d" | "descending" | "n" | null} SortableTitlePlugin~SortOrder
28561
27875
  */
28562
27876
 
28563
27877
  /** The sorting object which will be used for initialSort config.
@@ -28600,6 +27914,12 @@ SortableTitlePlugin.ColumnOptions;
28600
27914
  */
28601
27915
  SortableTitlePlugin.Options;
28602
27916
 
27917
+
27918
+ /** @type {Array.<Core>}
27919
+ * @private
27920
+ */
27921
+ SortableTitlePlugin.prototype._hosts = null; // For a plug-in that support multi-table
27922
+
28603
27923
  /** Order of item indicates sort priorities used in DataView. <br>
28604
27924
  * Each state contains column name{string}, sort order {string}, and rendering cell {ElementWrapper}
28605
27925
  * @private
@@ -28704,13 +28024,17 @@ var CODE_DOWN = "\u25BC";
28704
28024
  */
28705
28025
  var CODE_DIAMOND = "\u25CA";
28706
28026
 
28707
- /** @override */
28027
+ /** The name must be readonly and unique among all other plugins
28028
+ * @public
28029
+ * @return {string}
28030
+ */
28708
28031
  SortableTitlePlugin.prototype.getName = function () {
28709
28032
  return "SortableTitlePlugin"; // Read Only
28710
28033
  };
28711
28034
 
28712
- /**
28713
- * @override
28035
+ /** @public
28036
+ * @param {!Core} host
28037
+ * @param {Object=} options
28714
28038
  * @description Suppress google compiler for argument options because Internal Plugin doesn't support.
28715
28039
  * @suppress {checkTypes}
28716
28040
  */
@@ -28729,7 +28053,10 @@ SortableTitlePlugin.prototype.initialize = function (host, options) {
28729
28053
  this.config(options);
28730
28054
  };
28731
28055
 
28732
- /** @override */
28056
+ /**For disposing any resource
28057
+ * @public
28058
+ * @param {!Core} host
28059
+ */
28733
28060
  SortableTitlePlugin.prototype.unload = function (host) {
28734
28061
  var at = this._hosts.indexOf(host);
28735
28062
  if (at < 0) { return; }
@@ -29120,31 +28447,18 @@ SortableTitlePlugin.prototype.getSortOrder = function (colIndex) {
29120
28447
  * @return {number} Return negative value if there is no sorted column
29121
28448
  */
29122
28449
  SortableTitlePlugin.prototype.getSortedColumnIndex = function (priority) {
29123
- var state = this._sortStates[priority || 0];
29124
- if (state) {
29125
- var host = this._hosts[0];
29126
- var colCount = host ? host.getColumnCount() : 0;
29127
- for (var c = 0; c < colCount; ++c) {
29128
- var sortOptions = this._getSortOptions(c);
29129
- if (sortOptions === state) {
29130
- return c;
29131
- }
29132
- }
29133
- }
29134
- return -1;
28450
+ return this._getColumnIndexByOptions(this._sortStates[priority || 0]);
29135
28451
  };
29136
- /** @public
28452
+ /** Start with 0 (the first column that is being sorted). The highest number will be sorted last. Negative value means the specified column is not sorted
28453
+ * @public
29137
28454
  * @param {number} colIndex
29138
- * @return {number} Start with 0 (first column to be sorted) and end in the highest number. Negative means the specified column is not sorted
28455
+ * @return {number}
29139
28456
  */
29140
28457
  SortableTitlePlugin.prototype.getSortPriority = function (colIndex) {
29141
- var sortOptions = this._getSortOptions(colIndex);
29142
- if (sortOptions && sortOptions["sortOrder"]) {
29143
- var len = this._sortStates.length;
29144
- for (var i = 0; i < len; ++i) {
29145
- if (this._sortStates[i] === sortOptions) {
29146
- return i;
29147
- }
28458
+ var len = this._sortStates.length;
28459
+ for (var i = 0; i < len; ++i) {
28460
+ if (this._sortStates[i] === this._getSortOptions(colIndex)) {
28461
+ return i;
29148
28462
  }
29149
28463
  }
29150
28464
  return -1;
@@ -29157,7 +28471,7 @@ SortableTitlePlugin.prototype.isColumnSorted = function (colIndex) {
29157
28471
  return this.getSortPriority(colIndex) >= 0;
29158
28472
  };
29159
28473
  /** @public
29160
- * @return {Array.<Object> | null} Array of object with "colIndex" and "sortOrder"
28474
+ * @return {Array.<Object>} Array of object with "colIndex" and "sortOrder"
29161
28475
  */
29162
28476
  SortableTitlePlugin.prototype.getSortedColumns = function () {
29163
28477
  var len = this._sortStates.length;
@@ -29166,28 +28480,33 @@ SortableTitlePlugin.prototype.getSortedColumns = function () {
29166
28480
  var arr = new Array(len);
29167
28481
  for (var i = 0; i < len; ++i) {
29168
28482
  var colIndex = this.getSortedColumnIndex(i);
28483
+ var state = this._sortStates[i];
29169
28484
  arr[i] = {
29170
28485
  "colIndex": colIndex,
29171
- "sortOrder": this._sortStates[i]["sortOrder"] || "n"
28486
+ "field": state["field"] || "",
28487
+ "sortOrder": state["sortOrder"] || "n"
29172
28488
  };
29173
28489
  }
29174
28490
  return arr;
29175
28491
  };
28492
+ /** @public
28493
+ * @return {boolean}
28494
+ */
28495
+ SortableTitlePlugin.prototype.isSorting = function () {
28496
+ return this._sortStates.length ? true : false;
28497
+ };
29176
28498
 
29177
28499
  /** @public
29178
- * @param {number} colIndex
28500
+ * @param {number|string} colRef Column index or field
29179
28501
  * @param {string=} sortOrder "a" for ascending, "d" for descending, and "n" for no sorting
29180
28502
  * @param {Object=} opt_arg Event argument to be sent with preDataSorting event
29181
28503
  * @fires SortableTitlePlugin#preDataSorting
29182
28504
  * @fires SortableTitlePlugin#columnSorted
29183
28505
  */
29184
- SortableTitlePlugin.prototype.sortColumn = function (colIndex, sortOrder, opt_arg) {
29185
- if (colIndex >= 0) { // ColIndex can be greater than the host column count, to allow default sorting
29186
-
29187
- var state = this._preSortColumn(colIndex, sortOrder);
29188
- if (state) {
29189
- this._sortColumn([state], opt_arg);
29190
- }
28506
+ SortableTitlePlugin.prototype.sortColumn = function (colRef, sortOrder, opt_arg) {
28507
+ var state = this._prepareSorting(colRef, sortOrder);
28508
+ if (state) {
28509
+ this._sortColumn([state], opt_arg);
29191
28510
  }
29192
28511
  };
29193
28512
 
@@ -29203,7 +28522,14 @@ SortableTitlePlugin.prototype.sortColumns = function (sortOptions, opt_arg) {
29203
28522
  var states = [];
29204
28523
  for (var i = 0; i < sortOptions.length; i++) {
29205
28524
  var opt = sortOptions[i];
29206
- var state = this._preSortColumn(opt["colIndex"], opt["sortOrder"] || opt["order"]);
28525
+ var colRef = opt["colIndex"];
28526
+ if(colRef < 0 || colRef == null) {
28527
+ colRef = opt["field"];
28528
+ }
28529
+ var state = this._prepareSorting(
28530
+ colRef,
28531
+ opt["sortOrder"] || opt["order"]
28532
+ );
29207
28533
  if (state) {
29208
28534
  states[i] = state;
29209
28535
  }
@@ -29232,7 +28558,6 @@ SortableTitlePlugin.prototype.refresh = function () {
29232
28558
 
29233
28559
  /** @description Perform sorting with the same parameter. Alias to {@link SortableTitlePlugin#refresh}
29234
28560
  * @public
29235
- * @override
29236
28561
  * @function
29237
28562
  */
29238
28563
  SortableTitlePlugin.prototype.restoreUserActions = SortableTitlePlugin.prototype.refresh;
@@ -29300,20 +28625,24 @@ SortableTitlePlugin.prototype.setDataColumnNames = SortableTitlePlugin.prototype
29300
28625
  * @return {string} field A field used for sorting
29301
28626
  */
29302
28627
  SortableTitlePlugin.prototype.getColumnSortingField = function (colIndex) {
29303
- var options = this._getSortOptions(colIndex);
28628
+ var sortOptions = this._getSortOptions(colIndex);
29304
28629
  // options["field"] is already consolidated from field, sortBy, and sortable properties.
29305
- var field = (options) ? options["field"] : null;
28630
+ var field = (sortOptions) ? sortOptions["field"] : null;
29306
28631
 
29307
- if (field == null && !this._rowDefMode) { // Old CompositeGrid may stored sorting field in DataColumnName
28632
+ if (field == null && !this._rowDefMode) { // Old CompositeGrid may store sorting field in DataColumnName
29308
28633
  var host = this._hosts[0];
29309
28634
  if (host) {
29310
28635
  field = host.getDataColumnName(colIndex);
28636
+ if(field && sortOptions) {
28637
+ sortOptions["field"] = field; // Cache for later use
28638
+ }
29311
28639
  }
29312
28640
  }
29313
28641
 
29314
28642
  return field || "";
29315
28643
  };
29316
- /** @public
28644
+ /** This is equivalent to setting sortBy in the configuration object.
28645
+ * @public
29317
28646
  * @param {number} colIndex
29318
28647
  * @param {string|null} field A field used for sorting
29319
28648
  * @param {Function=} sortLogic
@@ -29334,21 +28663,26 @@ SortableTitlePlugin.prototype.setColumnSortingField = function (colIndex, field,
29334
28663
  }
29335
28664
  }
29336
28665
  };
29337
- /** @public
28666
+ /** Return array of the fields from the currently sorted columns
28667
+ * @public
29338
28668
  * @return {!Array.<string>} fields of each sorting states
29339
28669
  */
29340
28670
  SortableTitlePlugin.prototype.getColumnSortingFields = function () {
29341
- var ary = [];
28671
+ var len = this._sortStates.length;
28672
+ var ary = new Array(len);
29342
28673
  var host = this._hosts[0];
29343
- var colCount = host ? host.getColumnCount() : 0;
29344
- for (var c = 0; c < colCount; ++c) {
29345
- var sortOptions = this._getSortOptions(c);
29346
- if (sortOptions && sortOptions["sortOrder"]) {
29347
- var priority = this._sortStates.indexOf(sortOptions);
29348
- if (priority >= 0) {
29349
- ary[priority] = this.getColumnSortingField(c);
28674
+
28675
+ for(var i = 0; i < len; ++i) {
28676
+ var sortOptions = this._sortStates[i];
28677
+ var field = sortOptions["field"];
28678
+ if(!field && !this._rowDefMode) {
28679
+ var colIndex = this._getColumnIndexByOptions(sortOptions); // Slow
28680
+ field = host.getDataColumnName(colIndex);
28681
+ if(field) {
28682
+ sortOptions["field"] = field; // Cache for later use
29350
28683
  }
29351
28684
  }
28685
+ ary[i] = field || "";
29352
28686
  }
29353
28687
  return ary;
29354
28688
  };
@@ -29592,7 +28926,7 @@ SortableTitlePlugin.prototype._proceedSorting = function (hitObj) {
29592
28926
  if (this._canClickToSort(hitObj)) {
29593
28927
  var colIndex = hitObj["colIndex"];
29594
28928
  // _proceedSorting() method is always produced by user clicking at the header // Thus, this operation is guaranteed to be a user action
29595
- var state = this._preSortColumn(colIndex);
28929
+ var state = this._prepareSorting(colIndex);
29596
28930
  if (state) {
29597
28931
  this._sortColumn([state], { "isUserAction": true });
29598
28932
  }
@@ -29616,6 +28950,14 @@ SortableTitlePlugin.prototype._onMouseDown = function (e) {
29616
28950
  }
29617
28951
  };
29618
28952
  /** @private
28953
+ * @param {string} pluginName
28954
+ * @return {*|null}
28955
+ */
28956
+ SortableTitlePlugin.prototype._getPlugin = function(pluginName) {
28957
+ var host = this._hosts[0];
28958
+ return (host) ? host.getPlugin(pluginName) : null;
28959
+ };
28960
+ /** @private
29619
28961
  * @param {Core} grid
29620
28962
  * @param {MouseEvent} e
29621
28963
  */
@@ -29770,23 +29112,36 @@ SortableTitlePlugin.prototype.clearAllColumnSortingSequences = function () {
29770
29112
 
29771
29113
 
29772
29114
  /** @private
29773
- * @param {number} colIndex
29115
+ * @param {number|string} colRef Column index or field
29774
29116
  * @param {string=} sortOrder "a" for ascending, "d" for descending, and "n" for no sorting
29775
29117
  * @returns {Object} state Returns null, if nothing is changed
29776
29118
  */
29777
- SortableTitlePlugin.prototype._preSortColumn = function (colIndex, sortOrder) {
29778
- if (!this._maxCount) { return null; }
29119
+ SortableTitlePlugin.prototype._prepareSorting = function (colRef, sortOrder) {
29120
+ if (!this._maxCount) {
29121
+ return null;
29122
+ }
29779
29123
 
29780
- var priority = this.getSortPriority(colIndex);
29781
- var curState = (priority >= 0) ? this._sortStates[priority] : null;
29124
+ var colIndex = -1;
29125
+ var field = "";
29126
+ var priority = -1;
29127
+ if(typeof colRef === "number") {
29128
+ colIndex = colRef;
29129
+ field = this.getColumnSortingField(colIndex);
29130
+ priority = this.getSortPriority(colIndex);
29131
+ } else if(typeof colRef === "string") {
29132
+ field = colRef;
29133
+ colIndex = this._getColumnIndexByField(field);
29134
+ var fields = this.getColumnSortingFields();
29135
+ priority = fields.indexOf(field);
29136
+ }
29782
29137
 
29138
+ var curState = (priority >= 0) ? this._sortStates[priority] : null;
29783
29139
  var curOrder = curState ? curState["sortOrder"] : "n";
29784
29140
 
29785
29141
  // Getting next sort order
29786
29142
  var nextOrder = "n";
29787
- var sortingField = this.getColumnSortingField(colIndex);
29788
29143
  if (sortOrder == null) { // Auto order switch
29789
- var sortingSequence = this.getSortingSequence(sortingField);
29144
+ var sortingSequence = this.getSortingSequence(field);
29790
29145
 
29791
29146
  var sequenceIndex = sortingSequence.indexOf(curOrder);
29792
29147
  if (sequenceIndex < 0) {
@@ -29811,10 +29166,16 @@ SortableTitlePlugin.prototype._preSortColumn = function (colIndex, sortOrder) {
29811
29166
  }
29812
29167
 
29813
29168
  if (nextOrder === "a" || nextOrder === "d") { // Reorder sort states
29169
+ if(colIndex < 0 && !field) {
29170
+ return null;
29171
+ }
29814
29172
  if (!curState) {
29815
29173
  // TODO: Sort state object should not be sortOptions
29816
29174
  curState = this._newSortOptions(colIndex); // This may come with sortLogic
29817
29175
  }
29176
+ if(colIndex < 0) {
29177
+ curState["field"] = field;
29178
+ }
29818
29179
 
29819
29180
  this._sortStates.push(curState); // Latest sorting have lowest priority (multiColumn sorting)
29820
29181
  }
@@ -29841,7 +29202,7 @@ SortableTitlePlugin.prototype._preSortColumn = function (colIndex, sortOrder) {
29841
29202
 
29842
29203
  return { // TODO: Refactor this code as it is only used by "columnSorted" event (unnecessarily complex).
29843
29204
  "colIndex": colIndex,
29844
- "sortedField": sortingField,
29205
+ "sortedField": field,
29845
29206
  "sortOrder": nextOrder || "n",
29846
29207
  "prevOrder": curOrder,
29847
29208
  "clearedSortColIndexes": clearedSortColIndexes
@@ -29849,7 +29210,7 @@ SortableTitlePlugin.prototype._preSortColumn = function (colIndex, sortOrder) {
29849
29210
  };
29850
29211
 
29851
29212
  /** @private
29852
- * @param {Array.<Object>} states States from _preSortColumn for dispatching columnSorted event.
29213
+ * @param {Array.<Object>} states States from _prepareSorting for dispatching columnSorted event.
29853
29214
  * @param {Object=} opt_arg Event argument to be sent with preDataSorting event
29854
29215
  * @fires SortableTitlePlugin#preDataSorting
29855
29216
  * @fires SortableTitlePlugin#columnSorted
@@ -29876,8 +29237,8 @@ SortableTitlePlugin.prototype._sortColumn = function (states, opt_arg) {
29876
29237
  this._dispatch("columnSorted", res);
29877
29238
  };
29878
29239
 
29879
- /** @override
29880
- * @ignore
29240
+ /** @private
29241
+ * @param {Object} e
29881
29242
  */
29882
29243
  SortableTitlePlugin.prototype._onColumnAdded = function (e) {
29883
29244
  var t = this;
@@ -29899,8 +29260,8 @@ SortableTitlePlugin.prototype._onColumnAdded = function (e) {
29899
29260
  }
29900
29261
  };
29901
29262
 
29902
- /** @override
29903
- * @ignore
29263
+ /** @private
29264
+ * @param {Object} e
29904
29265
  * @fires SortableTitlePlugin#preDataSorting
29905
29266
  * @fires SortableTitlePlugin#columnSorted
29906
29267
  */
@@ -29952,7 +29313,7 @@ SortableTitlePlugin.prototype._sortDataView = function (opt_action) {
29952
29313
  sortLogics = new Array(sortCount);
29953
29314
  for (var i = 0; i < sortCount; ++i) {
29954
29315
  orders[i] = this._sortStates[i]["sortOrder"];
29955
- sortLogics[i] = this._sortStates[i]["sortLogic"];
29316
+ sortLogics[i] = this._sortStates[i]["sortLogic"]; // sortLogic can be null
29956
29317
  }
29957
29318
  if(this._rowDefMode) { // DataView in real-time grid has only ROW_DEF column
29958
29319
  c_ref = this._sortStates.map(SortableTitlePlugin._toRowDefField);
@@ -30034,7 +29395,7 @@ SortableTitlePlugin.prototype._updateSortableIndicator = function (hostIndex) {
30034
29395
 
30035
29396
  cell["addClass"]("sortable");
30036
29397
 
30037
- var priority = t._getColumnSortingStatePriority(col);
29398
+ var priority = t.getSortPriority(col);
30038
29399
  var state = t._sortStates[priority];
30039
29400
 
30040
29401
  var isSorting = state && state["sortOrder"] !== "n";
@@ -30105,18 +29466,40 @@ SortableTitlePlugin.prototype._createIconElem = function (icon, fallback) {
30105
29466
  };
30106
29467
 
30107
29468
  /** @private
30108
- * @param {number} colIndex
30109
- * @return {number} -1 means not found
29469
+ * @param {Object} sortOptions
29470
+ * @return {number}
30110
29471
  */
30111
- SortableTitlePlugin.prototype._getColumnSortingStatePriority = function (colIndex) {
30112
- var t = this;
30113
- for (var i = t._sortStates.length; --i >= 0;) {
30114
- var col = t.getSortedColumnIndex(i);
30115
- if (col === colIndex) return i;
29472
+ SortableTitlePlugin.prototype._getColumnIndexByOptions = function (sortOptions) {
29473
+ if(sortOptions) {
29474
+ var host = this._hosts[0];
29475
+ var colCount = host ? host.getColumnCount() : 0;
29476
+ for (var c = 0; c < colCount; ++c) {
29477
+ var colData = host.getColumnData(c); // Equivalent to _getSortOptions() method
29478
+ if (colData) {
29479
+ if(sortOptions === colData["sortableTitle"]) {
29480
+ return c;
29481
+ }
29482
+ }
29483
+ }
29484
+ }
29485
+ return -1;
29486
+ };
29487
+ /** @private
29488
+ * @param {string} field
29489
+ * @return {number}
29490
+ */
29491
+ SortableTitlePlugin.prototype._getColumnIndexByField = function (field) {
29492
+ if(field) {
29493
+ var host = this._hosts[0];
29494
+ var colCount = host ? host.getColumnCount() : 0;
29495
+ for (var c = 0; c < colCount; ++c) {
29496
+ if(field === this.getColumnSortingField(c)) {
29497
+ return c;
29498
+ }
29499
+ }
30116
29500
  }
30117
29501
  return -1;
30118
29502
  };
30119
-
30120
29503
  /** @private
30121
29504
  * @param {number} colIndex
30122
29505
  * @return {Object}
@@ -30139,10 +29522,7 @@ SortableTitlePlugin.prototype._newSortOptions = function (colIndex) {
30139
29522
  var host = this._hosts[0];
30140
29523
  var sortOptions = null;
30141
29524
  if (host && colIndex >= 0) {
30142
- var colData = host.getColumnData(colIndex);
30143
- if (!colData) {
30144
- colData = host.setColumnData(colIndex, {});
30145
- }
29525
+ var colData = host.getColumnData(colIndex); // colData is guaranteed to exist
30146
29526
  sortOptions = colData["sortableTitle"];
30147
29527
  if (!sortOptions) {
30148
29528
  sortOptions = colData["sortableTitle"] = {};
@@ -30222,8 +29602,6 @@ SortableTitlePlugin._proto = SortableTitlePlugin.prototype;
30222
29602
  // Plugins
30223
29603
 
30224
29604
 
30225
-
30226
-
30227
29605
  // Data
30228
29606
 
30229
29607
 
@@ -30275,8 +29653,6 @@ grid.SelectionList = util_SelectionList;
30275
29653
  grid.SectionSettings = util_SectionSettings;
30276
29654
 
30277
29655
  // Plugins
30278
- grid.Plugin = plugins_Plugin;
30279
- grid.DragAndDropTitlePlugin = plugins_DragAndDropTitlePlugin;
30280
29656
  grid.SortableTitlePlugin = plugins_SortableTitlePlugin;
30281
29657
  // tsd-enable
30282
29658