@refinitiv-ui/efx-grid 6.0.3 → 6.0.4

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 (178) 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/core/dist/core.css +1 -1
  6. package/lib/core/dist/core.js +389 -1070
  7. package/lib/core/dist/core.min.js +1 -1
  8. package/lib/core/es6/data/ColumnStats.d.ts +2 -2
  9. package/lib/core/es6/data/DataCache.d.ts +4 -4
  10. package/lib/core/es6/data/DataTable.d.ts +5 -5
  11. package/lib/core/es6/data/DataTable.js +1 -1
  12. package/lib/core/es6/data/DataView.d.ts +12 -12
  13. package/lib/core/es6/data/SegmentCollection.d.ts +3 -3
  14. package/lib/core/es6/data/WrappedView.d.ts +13 -13
  15. package/lib/core/es6/grid/Core.d.ts +29 -27
  16. package/lib/core/es6/grid/Core.js +26 -4
  17. package/lib/core/es6/grid/ILayoutGrid.d.ts +15 -15
  18. package/lib/core/es6/grid/LayoutGrid.js +54 -26
  19. package/lib/core/es6/grid/VirtualizedLayoutGrid.js +66 -0
  20. package/lib/core/es6/grid/components/Cell.d.ts +4 -4
  21. package/lib/core/es6/grid/components/CellFloatingPanel.d.ts +1 -1
  22. package/lib/core/es6/grid/components/CellSpans.d.ts +8 -8
  23. package/lib/core/es6/grid/components/Column.d.ts +1 -1
  24. package/lib/core/es6/grid/components/ElementWrapper.d.ts +6 -6
  25. package/lib/core/es6/grid/components/Scrollbar.d.ts +1 -1
  26. package/lib/core/es6/grid/components/StretchedCells.js +2 -2
  27. package/lib/core/es6/grid/plugins/SortableTitlePlugin.d.ts +14 -6
  28. package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +147 -81
  29. package/lib/core/es6/grid/util/Conflator.d.ts +2 -2
  30. package/lib/core/es6/grid/util/ElementFrameWork.d.ts +3 -3
  31. package/lib/core/es6/grid/util/HttpRequest.d.ts +2 -2
  32. package/lib/core/es6/grid/util/PercentBarRenderer.d.ts +1 -1
  33. package/lib/core/es6/grid/util/RangeBar.d.ts +1 -1
  34. package/lib/core/es6/grid/util/SectionSettings.d.ts +5 -5
  35. package/lib/core/es6/grid/util/SectionSettings.js +5 -0
  36. package/lib/core/es6/grid/util/SelectionList.d.ts +2 -2
  37. package/lib/core/es6/grid/util/TrackLayout.d.ts +7 -3
  38. package/lib/core/es6/grid/util/TrackLayout.js +27 -0
  39. package/lib/core/es6/grid/util/util.d.ts +2 -2
  40. package/lib/core/es6/index.d.ts +1 -5
  41. package/lib/core/es6/index.js +1 -7
  42. package/lib/core/es6/tr-grid-theme.js +1 -1
  43. package/lib/filter-dialog/lib/filter-dialog.d.ts +1 -0
  44. package/lib/filter-dialog/lib/filter-dialog.js +73 -26
  45. package/lib/filter-dialog/themes/base-checkbox.less +8 -1
  46. package/lib/filter-dialog/themes/base.less +69 -1
  47. package/lib/filter-dialog/themes/elemental/dark/checkbox-list.js +1 -1
  48. package/lib/filter-dialog/themes/elemental/dark/es5/all-elements.js +2 -2
  49. package/lib/filter-dialog/themes/elemental/dark/filter-dialog.js +1 -1
  50. package/lib/filter-dialog/themes/elemental/light/checkbox-list.js +1 -1
  51. package/lib/filter-dialog/themes/elemental/light/es5/all-elements.js +2 -2
  52. package/lib/filter-dialog/themes/elemental/light/filter-dialog.js +1 -1
  53. package/lib/filter-dialog/themes/halo/dark/checkbox-list.js +1 -1
  54. package/lib/filter-dialog/themes/halo/dark/es5/all-elements.js +2 -2
  55. package/lib/filter-dialog/themes/halo/dark/filter-dialog.js +1 -1
  56. package/lib/filter-dialog/themes/halo/light/checkbox-list.js +1 -1
  57. package/lib/filter-dialog/themes/halo/light/es5/all-elements.js +2 -2
  58. package/lib/filter-dialog/themes/halo/light/filter-dialog.js +1 -1
  59. package/lib/filter-dialog/themes/solar/charcoal/checkbox-list.js +1 -1
  60. package/lib/filter-dialog/themes/solar/charcoal/es5/all-elements.js +2 -2
  61. package/lib/filter-dialog/themes/solar/charcoal/filter-dialog.js +1 -1
  62. package/lib/filter-dialog/themes/solar/pearl/checkbox-list.js +1 -1
  63. package/lib/filter-dialog/themes/solar/pearl/es5/all-elements.js +2 -2
  64. package/lib/filter-dialog/themes/solar/pearl/filter-dialog.js +1 -1
  65. package/lib/grid/lib/efx-grid.d.ts +8 -5
  66. package/lib/grid/lib/efx-grid.js +10 -4
  67. package/lib/grid/themes/halo/dark/efx-grid.js +1 -1
  68. package/lib/grid/themes/halo/dark/es5/all-elements.js +1 -1
  69. package/lib/grid/themes/halo/efx-grid.less +33 -39
  70. package/lib/grid/themes/halo/light/efx-grid.js +1 -1
  71. package/lib/grid/themes/halo/light/es5/all-elements.js +1 -1
  72. package/lib/index.d.ts +2 -0
  73. package/lib/index.js +2 -0
  74. package/lib/row-segmenting/es6/RowSegmenting.d.ts +7 -2
  75. package/lib/row-segmenting/es6/RowSegmenting.js +94 -9
  76. package/lib/rt-grid/dist/rt-grid.js +567 -1171
  77. package/lib/rt-grid/dist/rt-grid.min.js +1 -1
  78. package/lib/rt-grid/es6/ColumnDefinition.d.ts +5 -3
  79. package/lib/rt-grid/es6/ColumnDefinition.js +17 -108
  80. package/lib/rt-grid/es6/DataConnector.d.ts +3 -3
  81. package/lib/rt-grid/es6/Grid.d.ts +17 -9
  82. package/lib/rt-grid/es6/Grid.js +201 -101
  83. package/lib/rt-grid/es6/RowDefSorter.d.ts +19 -0
  84. package/lib/rt-grid/es6/RowDefSorter.js +137 -0
  85. package/lib/rt-grid/es6/RowDefinition.d.ts +9 -7
  86. package/lib/rt-grid/es6/RowDefinition.js +6 -0
  87. package/lib/rt-grid/es6/SnapshotFiller.d.ts +3 -1
  88. package/lib/rt-grid/es6/SnapshotFiller.js +23 -0
  89. package/lib/tr-grid-checkbox/es6/Checkbox.d.ts +2 -2
  90. package/lib/tr-grid-checkbox/es6/Checkbox.js +38 -20
  91. package/lib/tr-grid-column-selection/es6/ColumnSelection.js +46 -9
  92. package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +8 -4
  93. package/lib/tr-grid-column-stack/es6/ColumnStack.js +240 -125
  94. package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.d.ts +1 -1
  95. package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +18 -12
  96. package/lib/tr-grid-in-cell-editing/es6/InCellEditing.d.ts +7 -4
  97. package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +93 -2
  98. package/lib/tr-grid-printer/es6/CellWriter.d.ts +3 -3
  99. package/lib/tr-grid-printer/es6/GridPrinter.d.ts +1 -1
  100. package/lib/tr-grid-printer/es6/GridPrinter.js +26 -13
  101. package/lib/tr-grid-printer/es6/PrintTrait.d.ts +2 -2
  102. package/lib/tr-grid-printer/es6/SectionWriter.d.ts +3 -3
  103. package/lib/tr-grid-row-dragging/es6/RowDragging.d.ts +2 -1
  104. package/lib/tr-grid-row-dragging/es6/RowDragging.js +29 -143
  105. package/lib/tr-grid-row-grouping/es6/RowGrouping.d.ts +7 -2
  106. package/lib/tr-grid-row-grouping/es6/RowGrouping.js +97 -7
  107. package/lib/tr-grid-row-selection/es6/RowSelection.js +10 -0
  108. package/lib/tr-grid-textformatting/es6/TextFormatting.d.ts +1 -1
  109. package/lib/tr-grid-textformatting/es6/TextFormatting.js +12 -0
  110. package/lib/tr-grid-util/es6/DragUI.d.ts +16 -0
  111. package/lib/tr-grid-util/es6/DragUI.js +214 -0
  112. package/lib/tr-grid-util/es6/ElementObserver.d.ts +2 -0
  113. package/lib/tr-grid-util/es6/ElementObserver.js +28 -1
  114. package/lib/tr-grid-util/es6/ElfUtil.js +1 -1
  115. package/lib/tr-grid-util/es6/FieldFormatter.js +7 -5
  116. package/lib/tr-grid-util/es6/GridPlugin.js +8 -4
  117. package/lib/tr-grid-util/es6/NumberFormatter.d.ts +2 -0
  118. package/lib/tr-grid-util/es6/NumberFormatter.js +64 -19
  119. package/lib/tr-grid-util/es6/RowPainter.js +41 -11
  120. package/lib/tr-grid-util/es6/formula/Formula.js +9 -1
  121. package/lib/types/es6/Checkbox.d.ts +2 -2
  122. package/lib/types/es6/ColumnStack.d.ts +8 -4
  123. package/lib/types/es6/CompositeGrid/ColumnSelectionPlugin.d.ts +3 -2
  124. package/lib/types/es6/CompositeGrid/ColumnWidthAdjustingPlugin.d.ts +2 -1
  125. package/lib/types/es6/CompositeGrid/CompositeGrid.d.ts +20 -18
  126. package/lib/types/es6/CompositeGrid/DragAndDropTitlePlugin.d.ts +2 -1
  127. package/lib/types/es6/CompositeGrid/DraggableContentPlugin.d.ts +3 -2
  128. package/lib/types/es6/CompositeGrid/Plugin.d.ts +28 -0
  129. package/lib/types/es6/CompositeGrid/ResizableTitlePlugin.d.ts +2 -1
  130. package/lib/types/es6/CompositeGrid/RowSelectionPlugin.d.ts +5 -4
  131. package/lib/types/es6/CompositeGrid/TreeIndentingPlugin.d.ts +2 -1
  132. package/lib/types/es6/CompositeGrid/index.d.ts +9 -9
  133. package/lib/types/es6/ConditionalColoring.d.ts +1 -1
  134. package/lib/types/es6/Core/data/ColumnStats.d.ts +2 -2
  135. package/lib/types/es6/Core/data/DataCache.d.ts +4 -4
  136. package/lib/types/es6/Core/data/DataTable.d.ts +5 -5
  137. package/lib/types/es6/Core/data/DataView.d.ts +12 -12
  138. package/lib/types/es6/Core/data/SegmentCollection.d.ts +3 -3
  139. package/lib/types/es6/Core/data/WrappedView.d.ts +13 -13
  140. package/lib/types/es6/Core/grid/Core.d.ts +29 -27
  141. package/lib/types/es6/Core/grid/ILayoutGrid.d.ts +15 -15
  142. package/lib/types/es6/Core/grid/components/Cell.d.ts +4 -4
  143. package/lib/types/es6/Core/grid/components/CellFloatingPanel.d.ts +1 -1
  144. package/lib/types/es6/Core/grid/components/CellSpans.d.ts +8 -8
  145. package/lib/types/es6/Core/grid/components/Column.d.ts +1 -1
  146. package/lib/types/es6/Core/grid/components/ElementWrapper.d.ts +6 -6
  147. package/lib/types/es6/Core/grid/components/Scrollbar.d.ts +1 -1
  148. package/lib/types/es6/Core/grid/plugins/SortableTitlePlugin.d.ts +14 -6
  149. package/lib/types/es6/Core/grid/util/Conflator.d.ts +2 -2
  150. package/lib/types/es6/Core/grid/util/ElementFrameWork.d.ts +3 -3
  151. package/lib/types/es6/Core/grid/util/HttpRequest.d.ts +2 -2
  152. package/lib/types/es6/Core/grid/util/PercentBarRenderer.d.ts +1 -1
  153. package/lib/types/es6/Core/grid/util/RangeBar.d.ts +1 -1
  154. package/lib/types/es6/Core/grid/util/SectionSettings.d.ts +5 -5
  155. package/lib/types/es6/Core/grid/util/SelectionList.d.ts +2 -2
  156. package/lib/types/es6/Core/grid/util/TrackLayout.d.ts +7 -3
  157. package/lib/types/es6/Core/grid/util/util.d.ts +2 -2
  158. package/lib/types/es6/Core/index.d.ts +1 -5
  159. package/lib/types/es6/ExtensionOptions.d.ts +2 -0
  160. package/lib/types/es6/InCellEditing.d.ts +7 -4
  161. package/lib/types/es6/RealtimeGrid/ColumnDefinition.d.ts +5 -3
  162. package/lib/types/es6/RealtimeGrid/DataConnector.d.ts +3 -3
  163. package/lib/types/es6/RealtimeGrid/Grid.d.ts +17 -9
  164. package/lib/types/es6/RealtimeGrid/RowDefSorter.d.ts +19 -0
  165. package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +9 -7
  166. package/lib/types/es6/RealtimeGrid/SnapshotFiller.d.ts +3 -1
  167. package/lib/types/es6/RowDragging.d.ts +2 -1
  168. package/lib/types/es6/RowGrouping.d.ts +7 -2
  169. package/lib/types/es6/RowSegmenting.d.ts +7 -2
  170. package/lib/types/es6/TextFormatting.d.ts +1 -1
  171. package/lib/versions.json +14 -13
  172. package/package.json +1 -1
  173. package/lib/core/es6/grid/plugins/DragAndDropTitlePlugin.d.ts +0 -24
  174. package/lib/core/es6/grid/plugins/DragAndDropTitlePlugin.js +0 -615
  175. package/lib/core/es6/grid/plugins/Plugin.d.ts +0 -28
  176. package/lib/core/es6/grid/plugins/Plugin.js +0 -272
  177. package/lib/types/es6/Core/grid/plugins/DragAndDropTitlePlugin.d.ts +0 -24
  178. package/lib/types/es6/Core/grid/plugins/Plugin.d.ts +0 -28
@@ -13,10 +13,10 @@ import SnapshotFiller from "./SnapshotFiller.js";
13
13
  import StyleLoader from "./StyleLoader.js";
14
14
  import FieldDefinition from "./FieldDefinition.js";
15
15
  import DataConnector from "./DataConnector.js";
16
+ import RowDefSorter from "./RowDefSorter.js";
16
17
 
17
18
  import { Core } from "../../core/es6/grid/Core.js";
18
19
  import { SortableTitlePlugin } from "../../core/es6/grid/plugins/SortableTitlePlugin.js";
19
- import { DragAndDropTitlePlugin } from "../../core/es6/grid/plugins/DragAndDropTitlePlugin.js";
20
20
  import { DataCache } from "../../core/es6/data/DataCache.js";
21
21
  import { DataTable } from "../../core/es6/data/DataTable.js";
22
22
  import { DataView } from "../../core/es6/data/DataView.js";
@@ -71,9 +71,11 @@ import { ElementWrapper } from "../../core/es6/grid/components/ElementWrapper.js
71
71
  * @property {number=} dataConflationRate=0 set delay for data to avoid to much sorting operation when data changed
72
72
  * @property {Function=} dataComposed Handler for dataComposed event
73
73
  * @property {boolean=} autoDateConversion=false If enabled, date-time field with numeric value will be automatically converted to native date object.
74
- * @property {boolean=} textSelect=false If enabled, user can select text
74
+ * @property {boolean=} textSelect=false If enabled, user can select content text by using mouse drag.
75
75
  * @property {string=} lang laguage for config localization date time, if null the default language is "en"
76
76
  * @property {Element=} scrollbarParent=null Element to be attached by grid's scrollbars, allowing them to move outside and avoid overlapping with the content.
77
+ * @property {boolean=} formulaEngine=false If enabled, field with leading equal sign will be treated as a formula and rows will be filled with the calculated values.
78
+ * @property {number=} adcPollingInterval=0 Length of polling interval for refreshing ADC data in milliseconds. The default value (0) means no polling.
77
79
  */
78
80
 
79
81
  /** @typedef {number|string|RowDefinition} Grid~RowReference
@@ -259,6 +261,7 @@ var Grid = function(placeholder, config) {
259
261
  t._onFieldLoadedError = t._onFieldLoadedError.bind(t);
260
262
 
261
263
  t._snapshotFillerDataChanged = t._snapshotFillerDataChanged.bind(t);
264
+ t._onPollingInterval = t._onPollingInterval.bind(t);
262
265
 
263
266
  t._streamingConflator = new Conflator(50, t._updateStreamingData);
264
267
  t._formulaConflator = new Conflator(300, t._onFormulaDataChanged);
@@ -272,6 +275,12 @@ var Grid = function(placeholder, config) {
272
275
  t._grid = new Core();
273
276
  t._grid._wrapper = this; // For back referencing
274
277
 
278
+ t._sorter = new RowDefSorter();
279
+ t._sorter.setContext("grid", this);
280
+ t._sorter.setContext("core", t._grid); // TODO: Handle multiple core grids
281
+
282
+ t._dateTimeUtil = DateTime;
283
+
275
284
  t._grid.listen("columnAdded", t._onColumnAdded); // Columns could be added by some plugins
276
285
 
277
286
  if(config) {
@@ -283,20 +292,15 @@ var Grid = function(placeholder, config) {
283
292
 
284
293
  var core = t._mainGrid.getCoreGrid();
285
294
  t._stp = core.getPlugin("SortableTitlePlugin");
286
- t._dtp = core.getPlugin("DragAndDropTitlePlugin");
287
295
  }
288
296
  if(config["SortableTitle"]) { // Exception for built-in plugin
289
297
  t._stp = config["SortableTitle"];
290
298
  }
291
- if(config["DragAndDropTitle"]) { // Exception for built-in plugin
292
- t._dtp = config["DragAndDropTitle"];
293
- }
294
299
  }
295
300
  if(!t._sharedDataSource) {
296
301
  t._dc = new DataCache();
297
302
  t._dc.listen("dataChanged", t._onDataChanged);
298
303
  t._dc.listen("dataComposed", t._onDataComposed);
299
- t._dc.listen("dataComposed", t._recalculateFormulas); // This will be called after _onDataComposed
300
304
 
301
305
  t._dt = new DataTable();
302
306
  t._dt.setSortingLogic(/** @type{Function} */(t._mainSorter));
@@ -307,7 +311,7 @@ var Grid = function(placeholder, config) {
307
311
  t._grid.setDataSource(t._dv); // Avoid triggering sorting
308
312
 
309
313
  if(t._stp) {
310
- this._sharedSorter = true;
314
+ t._sharedSorter = true;
311
315
  t._stp.listen("preDataSorting", t._onPreDataSorting);
312
316
  t._grid.loadPlugin(t._stp); // The plugin instance is shared and don't need to be reconfigured.
313
317
  } else { // Create built-in plugin
@@ -324,10 +328,6 @@ var Grid = function(placeholder, config) {
324
328
  // beforeInit is not called.
325
329
  t._grid.loadPlugin(t._stp, config);
326
330
  }
327
- if(!t._dtp) { // Create built-in plugin
328
- t._dtp = new DragAndDropTitlePlugin();
329
- }
330
- t._grid.loadPlugin(t._dtp);
331
331
 
332
332
  t._grid.listen("preSectionRender", t._onColumnHeaderBinding);
333
333
  t._grid.listen("postSectionDataBinding", t._onPostSectionDataBinding);
@@ -347,10 +347,6 @@ var Grid = function(placeholder, config) {
347
347
  t._connector.addEventListener("fieldAdded", t._onFieldAdded.bind(t));
348
348
  t._connector.addEventListener("fieldRemoved", t._onFieldRemoved.bind(t));
349
349
 
350
- t._fnEngine = new Engine();
351
- t._fnEngine.addEventListener("dataChanged", t._onFormulaDataChanged);
352
- t._fnEngine.addEventListener("dataRequired", t._onFormulaDataRequired);
353
-
354
350
  t.initialize(config);
355
351
  t.initSubscription();
356
352
 
@@ -404,10 +400,6 @@ Grid.prototype._subs = null;
404
400
  * @private
405
401
  */
406
402
  Grid.prototype._stp = null;
407
- /** @type {DragAndDropTitlePlugin}
408
- * @private
409
- */
410
- Grid.prototype._dtp = null;
411
403
  /** @type {Function}
412
404
  * @private
413
405
  */
@@ -425,6 +417,10 @@ Grid.prototype._snapshot = null;
425
417
  * @type {DataConnector}
426
418
  */
427
419
  Grid.prototype._connector = null;
420
+ /** @private
421
+ * @type {RowDefSorter}
422
+ */
423
+ Grid.prototype._sorter = null;
428
424
 
429
425
  /** @private
430
426
  * @type {Engine}
@@ -444,10 +440,6 @@ Grid.prototype._chainMembers = null;
444
440
  */
445
441
  Grid.prototype._chainConflator = null;
446
442
  /** @private
447
- * @type {boolean}
448
- */
449
- Grid.prototype._hasGroup = false;
450
- /** @private
451
443
  * @type {number}
452
444
  */
453
445
  Grid.prototype._clientWidth = NaN;
@@ -476,15 +468,34 @@ Grid.prototype._autoDateConversion = false;
476
468
  * @type {boolean}
477
469
  */
478
470
  Grid.prototype._textSelect = false;
479
- /** @private
480
- * @type {string}
471
+ /** @type {string}
472
+ * @private
481
473
  */
482
474
  Grid.prototype._lang = null;
483
- /**
475
+ /** @type {Object}
476
+ * @private
477
+ */
478
+ Grid.prototype._dateTimeUtil = null;
479
+ /** @type {boolean}
484
480
  * @private
485
- * @type {boolean}
486
481
  */
487
482
  Grid.prototype._initializing = false;
483
+ /** @type {number}
484
+ * @private
485
+ */
486
+ Grid.prototype._pollingInterval = 0;
487
+ /** @type {number}
488
+ * @private
489
+ */
490
+ Grid.prototype._pollingTimerId = 0;
491
+ /** @type {number}
492
+ * @private
493
+ */
494
+ Grid.prototype._lastPollingRequest = 0;
495
+ /** @type {boolean}
496
+ * @private
497
+ */
498
+ Grid.prototype._pollingEnabled = true;
488
499
 
489
500
 
490
501
  /** @public
@@ -495,8 +506,13 @@ Grid.prototype.dispose = function() {
495
506
  clearInterval(this._autoLayoutTimer);
496
507
  this._autoLayoutTimer = 0;
497
508
  }
509
+ if(this._pollingTimerId) {
510
+ clearTimeout(this._pollingTimerId);
511
+ this._pollingTimerId = 0;
512
+ }
498
513
  this.removeAllColumns(); // Some conflators are reset
499
514
  this.removeAllRows(); // Some conflators are reset
515
+ this._sorter.dispose();
500
516
  this._grid.dispose();
501
517
  this._connector.reset();
502
518
 
@@ -722,6 +738,12 @@ Grid.prototype.initialize = function(gridOption) {
722
738
  StyleLoader.chainIcon = gridOption["icons"]["rowGrouping"]["expander"];
723
739
  }
724
740
 
741
+ if(gridOption["formulaEngine"]) {
742
+ t._fnEngine = new Engine();
743
+ t._fnEngine.addEventListener("dataChanged", t._onFormulaDataChanged);
744
+ t._fnEngine.addEventListener("dataRequired", t._onFormulaDataRequired);
745
+ }
746
+
725
747
  var borders = gridOption["borders"];
726
748
  if (borders != null) {
727
749
  grid.toggleBorders(borders);
@@ -752,14 +774,6 @@ Grid.prototype.initialize = function(gridOption) {
752
774
  grid.getSection("title").setDefaultRowHeight(hRowHeight);
753
775
  }
754
776
 
755
- var noColumnDragging = gridOption["noColumnDragging"];
756
- if (noColumnDragging == null && gridOption["columnReorder"] != null) {
757
- noColumnDragging = !gridOption["columnReorder"];
758
- }
759
- if (noColumnDragging) {
760
- t._dtp.disable();
761
- }
762
-
763
777
  var val = gridOption["autoLayoutUpdate"];
764
778
  if(!t._autoLayoutTimer && val) {
765
779
  if(val !== "0" && val !== "false") { // HACK: Temporarily support incorrect data type
@@ -799,6 +813,10 @@ Grid.prototype.initialize = function(gridOption) {
799
813
  if(gridOption["scrollbarParent"] != null) {
800
814
  t._setScrollbarParent(gridOption["scrollbarParent"]);
801
815
  }
816
+ var pollingInterval = gridOption["adcPollingInterval"];
817
+ if(pollingInterval != null) {
818
+ t._pollingInterval = pollingInterval ? +pollingInterval : 0;
819
+ }
802
820
 
803
821
  // Column operations
804
822
  t.setColumns(cols);
@@ -873,7 +891,7 @@ Grid.prototype.initialize = function(gridOption) {
873
891
  var lang = gridOption["lang"];
874
892
  if(lang != null) {
875
893
  t._lang = lang;
876
- DateTime.setLocale(lang);
894
+ t._dateTimeUtil.setLocale(lang);
877
895
  }
878
896
 
879
897
  // Row operations
@@ -1013,13 +1031,19 @@ Grid.prototype.getConfigObject = function (gridOptions) {
1013
1031
  obj["autoDateConversion"] = true;
1014
1032
  }
1015
1033
 
1016
- if (this._textSelect) {
1034
+ if(this._textSelect) {
1017
1035
  obj["textSelect"] = true;
1018
1036
  }
1019
1037
 
1020
- if (this._lang) {
1038
+ if(this._lang) {
1021
1039
  obj["lang"] = this._lang;
1022
1040
  }
1041
+ if(this._fnEngine) {
1042
+ obj["formulaEngine"] = true;
1043
+ }
1044
+ if(this._pollingInterval) {
1045
+ obj["adcPollingInterval"] = this._pollingInterval;
1046
+ }
1023
1047
 
1024
1048
  // get all rows config
1025
1049
  var rowDefs = this.getAllRowDefinitions();
@@ -1055,7 +1079,6 @@ Grid.prototype.getConfigObject = function (gridOptions) {
1055
1079
  }
1056
1080
 
1057
1081
  // TODO: The following states need to be retrieved
1058
- // noColumnDragging
1059
1082
  // rowHighlighting
1060
1083
  // columnVirtualization
1061
1084
  // topFreezingCount, bottomFreezingCount
@@ -1066,6 +1089,27 @@ Grid.prototype.getConfigObject = function (gridOptions) {
1066
1089
  return obj;
1067
1090
  };
1068
1091
 
1092
+ /** @public
1093
+ * @ignore
1094
+ * @param {Object} dateTimeUtil
1095
+ */
1096
+ Grid.prototype.setDateTimeUtil = function(dateTimeUtil) {
1097
+ if(this._dateTimeUtil !== dateTimeUtil) {
1098
+ this._dateTimeUtil = dateTimeUtil;
1099
+ this._dateTimeUtil.setLocale(this._lang);
1100
+ }
1101
+ };
1102
+ /** @public
1103
+ * @param {string} lang
1104
+ */
1105
+ Grid.prototype.setLocale = function(lang) {
1106
+ if(lang && this._lang !== lang) {
1107
+ this._lang = lang;
1108
+ this._dateTimeUtil.setLocale(lang);
1109
+ this._grid.requestRowRefresh();
1110
+ }
1111
+ };
1112
+
1069
1113
  /** @private
1070
1114
  * @param {Object} defaultCol
1071
1115
  * @param {Array.<Object>} userColumns
@@ -1171,10 +1215,6 @@ Grid.prototype._onFieldRemoved = function(e) {
1171
1215
  * @param {number=} idx
1172
1216
  */
1173
1217
  Grid.prototype.insertColumn = function (columnOption, idx) {
1174
- if (typeof columnOption === "string") {
1175
- columnOption = { field: columnOption };
1176
- }
1177
-
1178
1218
  var colCount = this.getColumnCount();
1179
1219
  if(idx == null || idx > colCount) {
1180
1220
  idx = colCount;
@@ -1182,16 +1222,26 @@ Grid.prototype.insertColumn = function (columnOption, idx) {
1182
1222
 
1183
1223
  // no need to merge defaultColumn during initialize process
1184
1224
  // because columnOption already mutate by initialize function
1185
- var userOptions = (this._initializing) ? {} : cloneObject(this._defaultColumnOptions);
1186
- Grid._objectAssign(userOptions, columnOption);
1187
- userOptions["formulaEngine"] = this._fnEngine; // Adding extra option
1225
+ var configObj = (this._initializing) ? {} : cloneObject(this._defaultColumnOptions);
1226
+
1227
+ if (typeof columnOption === "string") {
1228
+ configObj["field"] = columnOption;
1229
+ } else { // columnOption is assumed to be an object
1230
+ for (var key in columnOption) {
1231
+ configObj[key] = columnOption[key];
1232
+ }
1233
+ }
1234
+
1235
+ if(this._fnEngine) {
1236
+ configObj["formulaEngine"] = this._fnEngine; // Adding extra option
1237
+ }
1188
1238
 
1189
- var colDef = new ColumnDefinition(userOptions, this);
1190
- userOptions[COL_DEF] = colDef;
1239
+ var colDef = new ColumnDefinition(configObj, this);
1240
+ configObj[COL_DEF] = colDef;
1191
1241
 
1192
1242
  // WARNING: width is processed twice by tr-grid and rt-grid
1193
1243
  // Inserting column also initializes prefined formatter
1194
- this._grid.insertColumn(idx, userOptions); // columnAdded is fired
1244
+ this._grid.insertColumn(idx, configObj); // columnAdded is fired
1195
1245
  };
1196
1246
 
1197
1247
 
@@ -1659,6 +1709,11 @@ Grid.prototype.removeDataFields = function(fieldRef, referrer) {
1659
1709
  * @param {string=} opt_order This can be "ascending", "descending", "none", "noOrder", or "originalOrder"
1660
1710
  */
1661
1711
  Grid.prototype.sortColumn = function(colRef, opt_order) {
1712
+ if(typeof colRef === "string") {
1713
+ this._stp.sortColumn(colRef, opt_order); // Allow sorting by field
1714
+ return;
1715
+ }
1716
+
1662
1717
  var colIndex = this.getColumnIndex(colRef);
1663
1718
  if(colIndex < 0) {
1664
1719
  this._stp.sortColumn(this.getSortedColumnIndex(), "n"); // reset current sorting
@@ -1759,9 +1814,9 @@ Grid.prototype.setColumnSorter = function(colRef, func) {
1759
1814
  if(colDef) {
1760
1815
  colDef.setSorter(func);
1761
1816
 
1762
- var sortedColumn = this.getSortedColumnIndex();
1817
+ var sortedColumn = this.getSortedColumnIndex(); // TODO: Support multi-column sorting
1763
1818
  if(sortedColumn === colIndex) {
1764
- this._columnSorter = colDef.getSorter();
1819
+ this._stp.refresh();
1765
1820
  }
1766
1821
  }
1767
1822
  };
@@ -1803,9 +1858,6 @@ Grid.prototype.insertRow = function(rowOption, rowRef) {
1803
1858
  var rowDef = new RowDefinition(rowOption);
1804
1859
  rowDef.setDataSource(this._dc); // This could also subscribe chain index/ric to JET/RTK
1805
1860
  this._initDuplicateRicData(rowDef);
1806
- if(rowDef.isFixedPosition()) {
1807
- this._hasGroup = true; // HACK: This is temporary solution
1808
- }
1809
1861
 
1810
1862
  rowDef.registerToView(this._dv, this._getRowId(rowRef));
1811
1863
  if(rowOption && rowOption["hidden"]) {
@@ -1850,7 +1902,6 @@ Grid.prototype.insertRows = function(rowOptions, rowRef, opt_fields) {
1850
1902
  }
1851
1903
  this.insertRow(rowOption, rowId); // Note that data view is being frozen, so only using row id will work properly
1852
1904
  }
1853
- this._updateGroupOrder(); // TODO: Update group order for all scenarios
1854
1905
  this._dt.freeze(prevState);
1855
1906
  };
1856
1907
  /** Add multiple rows without `ric` property in {@link RowDefinition}
@@ -2623,7 +2674,7 @@ Grid.prototype.updateColumnTitle = function() {
2623
2674
  * @return {boolean}
2624
2675
  */
2625
2676
  Grid.prototype.isSorting = function() {
2626
- return this.getSortedColumnIndex() >= 0;
2677
+ return this._stp.isSorting();
2627
2678
  };
2628
2679
  /** @public
2629
2680
  * @return {number}
@@ -2640,7 +2691,7 @@ Grid.prototype.getSortOrder = function() {
2640
2691
  /** @public
2641
2692
  */
2642
2693
  Grid.prototype.clearSort = function() {
2643
- this._stp.clearSortState();
2694
+ this._stp.clearSortState(); // WARNING: No event is dispatched
2644
2695
  };
2645
2696
 
2646
2697
  /** @private
@@ -2738,43 +2789,38 @@ Grid.prototype._updateStreamingData = function() {
2738
2789
  this._dt.dispatchGlobalChange();
2739
2790
  }
2740
2791
  };
2792
+
2741
2793
  /** @private
2794
+ * @param {Object} e
2742
2795
  */
2743
- Grid.prototype._updateGroupOrder = function() {
2744
- if(!this._hasGroup) { return; }
2745
- // TODO: Perform re-indexing of the data table, so that both data table and data view has the same index
2746
- // if(this.isSorting()) {
2747
- // this._dt.sortOnce(ROW_DEF, this.getSortOrder());
2748
- // }
2749
- var rowCount = this._dt.getRowCount();
2750
- var groupOrder = 0;
2751
- var dirty = 0;
2752
- var prevParent = null;
2753
- var prevFixedState = false;
2754
- for(var i = 0; i < rowCount; ++i) {
2755
- var rowDef = this._dt.getDataAt(i, ROW_DEF);
2756
- var curParent = rowDef.getParent();
2757
- var curFixedState = rowDef.isFixedPosition();
2758
- if(curFixedState || curFixedState !== prevFixedState || curParent !== prevParent) {
2759
- ++groupOrder;
2796
+ Grid.prototype._onPreDataSorting = function (e) {
2797
+ var field = "";
2798
+ var rowSorting = false;
2799
+ var sortLogic = null;
2800
+
2801
+ var states = this._stp.getSortingStates(); // WARNING: Use of deprecated function
2802
+ var state = states ? states[0] : null; // TODO: Support multi-column sorting
2803
+
2804
+ if(state) {
2805
+ field = state["field"] || "";
2806
+ var colIndex = this._stp.getSortedColumnIndex(0);
2807
+ var colDef = (colIndex >= 0) ? this.getColumnDefinition(colIndex) : null;
2808
+ this._sorter.setContext("colIndex", colIndex);
2809
+ this._sorter.setContext("colDef", colDef);
2810
+
2811
+ if(colDef) {
2812
+ field = colDef.getField(); // WARNING: Field and logic could be out of sync
2813
+ sortLogic = colDef.getSorter();
2814
+ rowSorting = colDef.isRowSorting();
2760
2815
  }
2761
- prevParent = curParent;
2762
- prevFixedState = curFixedState;
2763
- dirty |= rowDef.setGroupOrder(groupOrder);
2764
2816
  }
2765
- if(dirty && this.isSorting()){
2766
- this._stp.refresh();
2817
+ if(!sortLogic && field) {
2818
+ sortLogic = state["sortLogic"];
2767
2819
  }
2768
- };
2769
2820
 
2770
- /** @private
2771
- * @param {Object} e
2772
- */
2773
- Grid.prototype._onPreDataSorting = function (e) {
2774
- // TODO: Support multi-column sorting
2775
- var colIndex = this._stp.getSortedColumnIndex();
2776
- var colDef = (colIndex >= 0) ? this.getColumnDefinition(colIndex) : null;
2777
- this._columnSorter = (colDef) ? colDef._prepareSortContext(colIndex) : null;
2821
+ this._sorter.setField(field);
2822
+ this._sorter.setSortLogic(sortLogic);
2823
+ this._columnSorter = this._sorter.getSorter(rowSorting);
2778
2824
  };
2779
2825
  /** @private
2780
2826
  * @param {RowDefinition} rowDefA
@@ -2934,6 +2980,9 @@ Grid.prototype._onDataComposed = function(e) {
2934
2980
  if(!rowDef) {
2935
2981
  return;
2936
2982
  }
2983
+ if(!rowDef.getDataSource()) {
2984
+ return; // Somehow, rowDef is invalid and doesn't have data source
2985
+ }
2937
2986
 
2938
2987
  if(this._autoDateConversion) { // auto data conversion
2939
2988
  var field, value, dataType, colDef;
@@ -2959,13 +3008,17 @@ Grid.prototype._onDataComposed = function(e) {
2959
3008
  e["rowDef"] = rowDef;
2960
3009
  this._dispatch("dataComposed", e);
2961
3010
  }
3011
+
3012
+ this._recalculateFormulas(e);
2962
3013
  };
2963
3014
 
2964
3015
  /** @private
2965
3016
  * @param {Object=} e
2966
3017
  */
2967
3018
  Grid.prototype._recalculateFormulas = function(e) {
2968
- if(this._fnEngine.getFormulaCount() <= 0) { return; }
3019
+ if(!this._fnEngine || this._fnEngine.getFormulaCount() <= 0) {
3020
+ return;
3021
+ }
2969
3022
 
2970
3023
  if(e && e["rid"]) {
2971
3024
  this._fnEngine.calculate(/** @type{Object.<string, *>} */ (e["rowData"]), /** @type{Object.<string, *>} */ (e["changes"]));
@@ -2989,6 +3042,64 @@ Grid.prototype._snapshotFillerDataChanged = function (e) {
2989
3042
  for (var ric in data) {
2990
3043
  this.setRicData(ric, data[ric]);
2991
3044
  }
3045
+ if(!this._lastPollingRequest) { // This is the first time we receive successful ADC response
3046
+ this._lastPollingRequest = 1; // Allow polling to be started
3047
+ }
3048
+ this._startPolling();
3049
+ };
3050
+ /** @private
3051
+ */
3052
+ Grid.prototype._startPolling = function () {
3053
+ if(this._pollingEnabled && this._pollingInterval) {
3054
+ if(this._lastPollingRequest && !this._pollingTimerId) {
3055
+ var now = new Date();
3056
+ this._lastPollingRequest = now.getTime();
3057
+ this._pollingTimerId = setTimeout(this._onPollingInterval, this._pollingInterval);
3058
+ }
3059
+ }
3060
+ };
3061
+ /** @private
3062
+ */
3063
+ Grid.prototype._onPollingInterval = function () {
3064
+ this._pollingTimerId = 0;
3065
+ if(this._pollingEnabled && this._pollingInterval) {
3066
+ this.refreshADCData();
3067
+ this._startPolling();
3068
+ }
3069
+ };
3070
+ /** @public
3071
+ * @param {boolean=} activated=true
3072
+ */
3073
+ Grid.prototype.activateADCPolling = function (activated) {
3074
+ if(activated !== false) {
3075
+ this._pollingEnabled = true;
3076
+ // Make immediate request after re-activation if it has been a long time
3077
+ var now = new Date();
3078
+ if(this._lastPollingRequest) {
3079
+ var diff = now.getTime() - this._lastPollingRequest;
3080
+ if(diff > this._pollingInterval) {
3081
+ this.refreshADCData();
3082
+ }
3083
+ }
3084
+ this._startPolling();
3085
+ } else {
3086
+ this._pollingEnabled = false;
3087
+ }
3088
+ };
3089
+ /** Force re-requesting ADC data to immediately update the data
3090
+ * @public
3091
+ * @return {boolean} Return true, if a request has been made
3092
+ */
3093
+ Grid.prototype.refreshADCData = function () {
3094
+ var dirty = this._snapshot.addFields(this._connector.getAllFields());
3095
+ if(dirty) {
3096
+ dirty = this._snapshot.addRics(this._connector.getAllRics());
3097
+ if(dirty) {
3098
+ return true;
3099
+ }
3100
+ }
3101
+ this._lastPollingRequest = 0; // No ADC field or RIC detected. Prevent polling from continuing
3102
+ return false;
2992
3103
  };
2993
3104
 
2994
3105
  /** @private
@@ -3047,16 +3158,5 @@ Grid.prototype._logData = function(rowDefs, options) {
3047
3158
  console.table(tbl); // eslint-disable-line
3048
3159
  };
3049
3160
 
3050
- /** @private
3051
- * @function
3052
- * @param {Object} to
3053
- * @param {Object} from
3054
- */
3055
- Grid._objectAssign = function (to, from) {
3056
- for (var key in from) {
3057
- to[key] = from[key];
3058
- }
3059
- };
3060
-
3061
3161
  export { Grid };
3062
3162
  export default Grid;
@@ -0,0 +1,19 @@
1
+
2
+
3
+ declare class RowDefSorter {
4
+
5
+ constructor();
6
+
7
+ public dispose(): void;
8
+
9
+ public getSorter(rowSorting?: boolean): ((...params: any[]) => any)|null;
10
+
11
+ public setSortLogic(func?: ((...params: any[]) => any)): void;
12
+
13
+ public setField(field: string): void;
14
+
15
+ public setContext(key: string, value: any): void;
16
+
17
+ }
18
+
19
+ export default RowDefSorter;