@refinitiv-ui/efx-grid 6.0.27 → 6.0.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. package/lib/core/dist/core.js +247 -29
  2. package/lib/core/dist/core.min.js +1 -1
  3. package/lib/core/es6/data/DataTable.d.ts +1 -1
  4. package/lib/core/es6/data/DataTable.js +3 -2
  5. package/lib/core/es6/data/DataView.d.ts +1 -1
  6. package/lib/core/es6/data/DataView.js +3 -2
  7. package/lib/core/es6/data/Segment.d.ts +1 -1
  8. package/lib/core/es6/data/Segment.js +12 -3
  9. package/lib/core/es6/data/SegmentCollection.d.ts +1 -1
  10. package/lib/core/es6/data/SegmentCollection.js +3 -2
  11. package/lib/core/es6/grid/Core.d.ts +17 -3
  12. package/lib/core/es6/grid/Core.js +226 -20
  13. package/lib/grid/index.js +1 -1
  14. package/lib/row-segmenting/es6/RowSegmenting.js +21 -2
  15. package/lib/rt-grid/dist/rt-grid.js +418 -238
  16. package/lib/rt-grid/dist/rt-grid.min.js +1 -1
  17. package/lib/rt-grid/es6/ColumnDefinition.d.ts +2 -2
  18. package/lib/rt-grid/es6/ColumnDefinition.js +71 -70
  19. package/lib/rt-grid/es6/Grid.d.ts +9 -2
  20. package/lib/rt-grid/es6/Grid.js +55 -132
  21. package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +3 -3
  22. package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +9 -27
  23. package/lib/tr-grid-column-stack/es6/ColumnStack.js +2 -8
  24. package/lib/tr-grid-util/es6/GridPlugin.d.ts +6 -0
  25. package/lib/tr-grid-util/es6/GridPlugin.js +67 -0
  26. package/lib/types/es6/ColumnGrouping.d.ts +3 -3
  27. package/lib/types/es6/Core/data/DataTable.d.ts +1 -1
  28. package/lib/types/es6/Core/data/DataView.d.ts +1 -1
  29. package/lib/types/es6/Core/data/Segment.d.ts +1 -1
  30. package/lib/types/es6/Core/data/SegmentCollection.d.ts +1 -1
  31. package/lib/types/es6/Core/grid/Core.d.ts +17 -3
  32. package/lib/types/es6/RealtimeGrid/ColumnDefinition.d.ts +2 -2
  33. package/lib/types/es6/RealtimeGrid/Grid.d.ts +9 -2
  34. package/lib/versions.json +4 -4
  35. package/package.json +1 -1
@@ -13389,14 +13389,23 @@ Segment.prototype.addChild = function(rid, dataId) {
13389
13389
  };
13390
13390
  /** @public
13391
13391
  * @param {Array.<string>} rids
13392
+ * @param {Array.<string>=} dataIds Row ids for retrieving data
13392
13393
  * @return {boolean}
13393
13394
  */
13394
- Segment.prototype.addChildren = function(rids) {
13395
+ Segment.prototype.addChildren = function(rids, dataIds) {
13395
13396
  var rowIds = Array.isArray(rids) ? rids : [rids];
13396
13397
  var rowCount = rowIds.length;
13397
13398
  var dirty = 0;
13398
- for(var i = 0; i < rowCount; ++i) {
13399
- dirty |= this.addChild(rowIds[i]);
13399
+ var i;
13400
+ if(dataIds != null) {
13401
+ dataIds = Array.isArray(dataIds) ? dataIds : [dataIds];
13402
+ for(i = 0; i < rowCount; ++i) {
13403
+ dirty |= this.addChild(rowIds[i], dataIds[i]);
13404
+ }
13405
+ } else {
13406
+ for(i = 0; i < rowCount; ++i) {
13407
+ dirty |= this.addChild(rowIds[i]);
13408
+ }
13400
13409
  }
13401
13410
  return dirty ? true : false;
13402
13411
  };
@@ -14222,12 +14231,13 @@ SegmentCollection.prototype.addSegmentChild = function(segmentId, rid, dataId) {
14222
14231
  /** @public
14223
14232
  * @param {string} segmentId
14224
14233
  * @param {Array.<string>} rids
14234
+ * @param {Array.<string>=} dataIds Row ids for retrieving data
14225
14235
  * @return {boolean} Returns true if there is any change. Otherwise, returns false
14226
14236
  */
14227
- SegmentCollection.prototype.addSegmentChildren = function(segmentId, rids) {
14237
+ SegmentCollection.prototype.addSegmentChildren = function(segmentId, rids, dataIds) {
14228
14238
  var segment = this._segments[segmentId];
14229
14239
  if(segment && !segment.isSubSegment()) {
14230
- return segment.addChildren(rids);
14240
+ return segment.addChildren(rids, dataIds);
14231
14241
  }
14232
14242
  return false;
14233
14243
  };
@@ -15691,11 +15701,12 @@ DataTable.prototype.addSegmentChild = function(segmentId, rid, dataId) {
15691
15701
  /** @public
15692
15702
  * @param {string} segmentId Row id
15693
15703
  * @param {Array.<string>} rids Row id
15704
+ * @param {Array.<string>=} dataIds Row ids for retrieving data
15694
15705
  * @return {boolean} Return true if there is any change
15695
15706
  */
15696
- DataTable.prototype.addSegmentChildren = function(segmentId, rids) {
15707
+ DataTable.prototype.addSegmentChildren = function(segmentId, rids, dataIds) {
15697
15708
  if(this._segments) {
15698
- var dirty = this._segments.addSegmentChildren(segmentId, rids);
15709
+ var dirty = this._segments.addSegmentChildren(segmentId, rids, dataIds);
15699
15710
  if(dirty) {
15700
15711
  if(this._sort(null)) {
15701
15712
  this._dispatchPositionChange();
@@ -20864,13 +20875,14 @@ DataView.prototype.addSegmentChild = function(segmentRef, rowRef, dataId) {
20864
20875
  /** @public
20865
20876
  * @param {string|number} segmentRef Row id or row index
20866
20877
  * @param {Array.<string|number>} rowRefs Array of row ids or row indices
20878
+ * @param {Array.<string>=} dataIds Row ids for retrieving data
20867
20879
  * @return {boolean} Return true if there is any change
20868
20880
  */
20869
- DataView.prototype.addSegmentChildren = function(segmentRef, rowRefs) {
20881
+ DataView.prototype.addSegmentChildren = function(segmentRef, rowRefs, dataIds) {
20870
20882
  if(this._dt._getSegmentSeparators()) {
20871
20883
  var segmentId = this._toRowId(segmentRef);
20872
20884
  var rowIds = this._toRowIds(rowRefs);
20873
- return this._dt.addSegmentChildren(segmentId, rowIds);
20885
+ return this._dt.addSegmentChildren(segmentId, rowIds, dataIds);
20874
20886
  }
20875
20887
  return false;
20876
20888
  };
@@ -25407,7 +25419,7 @@ Core_Core.prototype._groupDefs = null;
25407
25419
  * @return {string}
25408
25420
  */
25409
25421
  Core_Core.getVersion = function () {
25410
- return "5.1.35";
25422
+ return "5.1.38";
25411
25423
  };
25412
25424
  /** {@link ElementWrapper#dispose}
25413
25425
  * @override
@@ -25523,6 +25535,12 @@ Core_Core.prototype.getConfigObject = function (gridOptions) {
25523
25535
  }
25524
25536
 
25525
25537
  var columnDef = this._getColumnDef(colIndex);
25538
+ if(columnDef["userId"]) {
25539
+ column["id"] = columnDef["userId"];
25540
+ }
25541
+ if(columnDef["field"]) {
25542
+ column["field"] = columnDef["field"];
25543
+ }
25526
25544
  if (columnDef["styles"]) {
25527
25545
  column["styles"] = columnDef["styles"];
25528
25546
  }
@@ -26607,6 +26625,126 @@ Core_Core.prototype._moveColumn = function (fromCol, destCol) {
26607
26625
  return true;
26608
26626
  };
26609
26627
 
26628
+ /** If source column is not found, no operation is performed. If destination column is not found, the source column will be moved to the last position.<br>
26629
+ * Note: this method behaves slightly different from moveColumn method in that it always put source column at the position before the specified destination column, while moveColumn method will put column at exactly at the destination index.
26630
+ * @public
26631
+ * @param {number|string} srcCol Column Id or index
26632
+ * @param {(number|string)=} destCol Column Id or index of the destination
26633
+ * @return {boolean} Return true if there is any change, and false otherwise
26634
+ * @see {@link Core#moveColumn}
26635
+ * @example
26636
+ * grid.moveColumnById(3, 1); // Move column 3 to position before column 1
26637
+ * grid.moveColumnById(0, 2); // Move column 0 to position before column 2 (column index 1)
26638
+ * grid.moveColumnById(0, 1); // Nothing is moved
26639
+ * grid.moveColumnById("sourceColumnId", "anotherId");
26640
+ * grid.moveColumnById("sourceColumnId", ""); // move to the last position
26641
+ */
26642
+ Core_Core.prototype.moveColumnById = function (srcCol, destCol) {
26643
+ var colCount = this.getColumnCount();
26644
+ var srcIndex = this.getColumnIndex(srcCol);
26645
+ if(srcIndex < 0 || srcIndex >= colCount) {
26646
+ return false;
26647
+ }
26648
+ var destIndex = destCol != null ? this.getColumnIndex(destCol) : -1;
26649
+ if(destIndex < 0) {
26650
+ destIndex = colCount;
26651
+ }
26652
+ return this._moveColumnByIndex(srcIndex, destIndex);
26653
+ };
26654
+ /** Move column without verification for better performance
26655
+ * @private
26656
+ * @param {number} srcIndex Column index
26657
+ * @param {number} destIndex Column index of the destination
26658
+ * @return {boolean} Return true if there is any change, and false otherwise
26659
+ */
26660
+ Core_Core.prototype._moveColumnByIndex = function (srcIndex, destIndex) {
26661
+ if(srcIndex < destIndex) { // Ensure that the source column is put in front of the destination index
26662
+ --destIndex;
26663
+ }
26664
+ if(srcIndex === destIndex) {
26665
+ return false;
26666
+ }
26667
+ return this.moveColumn(srcIndex, destIndex);
26668
+ };
26669
+ /** @public
26670
+ * @param {number|string|Array.<number|string>} colRefs List of column index or column id to be moved
26671
+ * @param {(number|string)=} destCol Destination position where the moved columns will be placed BEFORE the specified position. This can be column id or index
26672
+ * @return {boolean} Return true if there is any change, and false otherwise
26673
+ */
26674
+ Core_Core.prototype.reorderColumns = function (colRefs, destCol) {
26675
+ var destId = "";
26676
+ if(typeof destCol === "number") {
26677
+ destId = this.getColumnId(destCol);
26678
+ } else if(destCol) {
26679
+ destId = destCol;
26680
+ }
26681
+
26682
+ if(Array.isArray(colRefs)) {
26683
+ var srcLen = colRefs.length;
26684
+ if(srcLen > 1) {
26685
+ var colIds = this.getColumnIds();
26686
+ var colCount = colIds.length;
26687
+ var srcIds = [];
26688
+ var invalidDest = false;
26689
+ var i, srcId, srcIdx;
26690
+ for(i = 0; i < srcLen; ++i) {
26691
+ var colRef = colRefs[i];
26692
+ if(typeof colRef === "number") {
26693
+ srcIdx = colRef;
26694
+ srcId = colIds[colRef] || "";
26695
+ } else {
26696
+ srcId = colRef;
26697
+ srcIdx = colIds.indexOf(srcId);
26698
+ }
26699
+ if(srcId && srcIdx >= 0) {
26700
+ srcIds.push(srcId);
26701
+ if(destId === srcId) {
26702
+ invalidDest = true; // Destination must not exist in source columns
26703
+ }
26704
+ }
26705
+ }
26706
+
26707
+ var destIdx;
26708
+ srcLen = srcIds.length;
26709
+ if(invalidDest) { // Find the next valid destination where it is not contained in the source columns
26710
+ destIdx = this.getColumnIndex(destId);
26711
+ if(destIdx >= 0) {
26712
+ while(++destIdx < colCount) {
26713
+ destId = colIds[destIdx];
26714
+ if(srcIds.indexOf(destId) < 0) {
26715
+ break;
26716
+ }
26717
+ }
26718
+ }
26719
+ if(destIdx < 0 || destIdx >= colCount) {
26720
+ destId = "";
26721
+ }
26722
+ }
26723
+
26724
+ var dirty = 0;
26725
+ for(i = srcLen; --i >= 0;) {
26726
+ srcId = srcIds[i]; // Only valid source columns are left at this point
26727
+ srcIdx = this.getColumnIndex(srcId);
26728
+ destIdx = this.getColumnIndex(destId);
26729
+ if(destIdx < 0) { // Insert to the back when id is not found
26730
+ destIdx = colCount;
26731
+ }
26732
+ dirty |= this._moveColumnByIndex(srcIdx, destIdx);
26733
+ destId = srcId;
26734
+ }
26735
+ return dirty ? true : false;
26736
+ } else {
26737
+ return this.moveColumnById(colRefs[0], destId);
26738
+ }
26739
+ }
26740
+
26741
+ if(colRefs != null) {
26742
+ // colRefs will be a number or string
26743
+ return this.moveColumnById(colRefs, destId);
26744
+ }
26745
+ return false;
26746
+ };
26747
+
26610
26748
  /** @public
26611
26749
  * @ignore
26612
26750
  * @return {!TrackLayout}
@@ -26658,9 +26796,14 @@ Core_Core.prototype._deserializeColumn = function (index, jsonObj) {
26658
26796
  var colId = jsonObj["id"];
26659
26797
  if(colId && typeof colId === "string") {
26660
26798
  colDef["id"] = colId; // WARNING: We do not guarantee uniqueness of user id
26799
+ colDef["userId"] = colId;
26800
+ }
26801
+ var field = jsonObj["field"];
26802
+ if(field && typeof field === "string") {
26803
+ colDef["field"] = field;
26661
26804
  }
26662
26805
 
26663
- var value = jsonObj["dataColumnName"];
26806
+ var value = jsonObj["dataColumnName"]; // Deprecated
26664
26807
  if (value != null) {
26665
26808
  colDef["dataColumnName"] = value;
26666
26809
  }
@@ -28103,24 +28246,6 @@ Core_Core.prototype.getRelativePosition = function (obj, context) {
28103
28246
  return ret_obj;
28104
28247
  };
28105
28248
 
28106
- /** Find column index by column id or data column name
28107
- * @public
28108
- * @param {string} str Column id or data column name
28109
- * @return {number} Return negative value if there is no match
28110
- */
28111
- Core_Core.prototype.getColumnIndex = function (str) {
28112
- if(str) {
28113
- var colCount = this.getColumnCount();
28114
- for(var c = 0; c < colCount; ++c) {
28115
- var colDef = this._getColumnDef(c);
28116
- if(str === colDef["id"] || str === colDef["dataColumnName"]) {
28117
- return c;
28118
- }
28119
- }
28120
- }
28121
- return -1;
28122
- };
28123
-
28124
28249
  /** @public
28125
28250
  * @return {!ElementWrapper}
28126
28251
  */
@@ -29719,6 +29844,99 @@ Core_Core.prototype.getColumnIds = function () {
29719
29844
  return ary;
29720
29845
  };
29721
29846
 
29847
+ /** @public
29848
+ * @param {number} colIndex
29849
+ * @param {string} field
29850
+ */
29851
+ Core_Core.prototype.setColumnField = function (colIndex, field) {
29852
+ this._getColumnDef(colIndex)["field"] = field || "";
29853
+ };
29854
+ /** @public
29855
+ * @param {number} colIndex
29856
+ * @return {string} Return empty string if the specified column does not exist
29857
+ */
29858
+ Core_Core.prototype.getColumnField = function (colIndex) {
29859
+ if(colIndex >= 0 && colIndex < this.getColumnCount()) {
29860
+ return this._getColumnDef(colIndex)["field"] || "";
29861
+ }
29862
+ return "";
29863
+ };
29864
+ /** @public
29865
+ * @return {!Array.<string>} Return all column ids from existing column
29866
+ */
29867
+ Core_Core.prototype.getColumnFields = function () {
29868
+ var colCount = this.getColumnCount();
29869
+ var ary = new Array(colCount);
29870
+ for(var c = 0; c < colCount; ++c) {
29871
+ ary[c] = this._getColumnDef(c)["field"] || "";
29872
+ }
29873
+ return ary;
29874
+ };
29875
+
29876
+ /** Get column index by column id or column field
29877
+ * @public
29878
+ * @param {string|number} colRef Column id or data column name
29879
+ * @return {number} Return negative value if there is no match
29880
+ */
29881
+ Core_Core.prototype.getColumnIndex = function (colRef) {
29882
+ if(typeof colRef === "number") {
29883
+ return colRef;
29884
+ } else if(colRef) {
29885
+ var str = colRef;
29886
+ var colCount = this.getColumnCount();
29887
+ for(var c = 0; c < colCount; ++c) {
29888
+ var colDef = this._getColumnDef(c);
29889
+ if(str === colDef["id"] || str === colDef["field"]) {
29890
+ return c;
29891
+ }
29892
+ }
29893
+ }
29894
+ return -1;
29895
+ };
29896
+ /** Any invalid column reference will be excluded from the output array
29897
+ * @public
29898
+ * @param {Array.<number|string>} colRefs
29899
+ * @return {!Array.<number>} Return negative value if there is no match
29900
+ */
29901
+ Core_Core.prototype.getColumnIndices = function (colRefs) {
29902
+ var ary = [];
29903
+ var colCount = this.getColumnCount();
29904
+ var inputAry = Array.isArray(colRefs) ? colRefs : [colRefs];
29905
+ var len = inputAry.length;
29906
+ // Verify user input
29907
+ for(var i = 0; i < len; ++i) {
29908
+ var colIndex = this.getColumnIndex(inputAry[i]);
29909
+ if(colIndex >= 0 && colIndex < colCount) {
29910
+ ary.push(colIndex); // WARNING: We have not check for duplication
29911
+ }
29912
+ }
29913
+ return ary;
29914
+ };
29915
+
29916
+ /** Get a map from column id and field to column index. This should be useful when finding multiple column indices.
29917
+ * @public
29918
+ * @return {!Object.<string, number>}
29919
+ */
29920
+ Core_Core.prototype.getColumnIndexMap = function () {
29921
+ var colCount = this.getColumnCount();
29922
+ var obj = {};
29923
+ var str = "";
29924
+ for(var c = 0; c < colCount; ++c) {
29925
+ var colDef = this._getColumnDef(c);
29926
+
29927
+ str = colDef["field"];
29928
+ if(str) {
29929
+ obj[str] = c;
29930
+ }
29931
+
29932
+ str = colDef["id"];
29933
+ if(str) {
29934
+ obj[str] = c;
29935
+ }
29936
+ }
29937
+ return obj;
29938
+ };
29939
+
29722
29940
 
29723
29941
  /** @private */
29724
29942
  Core_Core.prototype._onWindowResize = function() {