@refinitiv-ui/efx-grid 6.0.129 → 6.0.130

Sign up to get free protection for your applications and to get access to all the features.
@@ -621,7 +621,7 @@ Core.prototype._hasPendingRowChange = false;
621
621
  * @return {string}
622
622
  */
623
623
  Core.getVersion = function () {
624
- return "5.1.129";
624
+ return "5.1.130";
625
625
  };
626
626
  /** {@link ElementWrapper#dispose}
627
627
  * @override
@@ -2352,21 +2352,45 @@ Core.prototype.setColumnBackgroundColor = function(colIndex, color) {
2352
2352
  }
2353
2353
 
2354
2354
  if(settings.getType() !== "content") {
2355
- let rowCount = section.getRowCount();
2356
- for(let r = 0; r < rowCount; r++) {
2357
- let cellSpan = section.getCellColSpan(colIndex, r);
2358
- if(cellSpan > 1) { continue; }
2359
- let cell = section.getCell(colIndex, r);
2360
- if(cell) {
2361
- cell.setStyle("backgroundColor", color);
2362
- }
2363
- }
2355
+ this._applyCellsBackgroundColor(section, colIndex, color);
2364
2356
  } else {
2365
2357
  let column = section.getColumn(colIndex);
2366
2358
  column.setStyle("backgroundColor", color);
2367
2359
  }
2368
2360
  }
2369
2361
  };
2362
+ /** @private
2363
+ * @param {ILayoutGrid} section
2364
+ * @param {number} colIndex
2365
+ * @param {string} color
2366
+ */
2367
+ Core.prototype._applyCellsBackgroundColor = function(section, colIndex, color) {
2368
+ let rowCount = section.getRowCount();
2369
+ for(let r = 0; r < rowCount; r++) {
2370
+ let cellSpan = section.getCellColSpan(colIndex, r);
2371
+ if(cellSpan > 1) { continue; }
2372
+ let cell = section.getCell(colIndex, r);
2373
+ if(cell) {
2374
+ cell.setStyle("backgroundColor", color);
2375
+ }
2376
+ }
2377
+ };
2378
+ /** @public
2379
+ * @ignore
2380
+ * @param {ILayoutGrid} section
2381
+ */
2382
+ Core.prototype.applyColumnsBackgroundColor = function(section) {
2383
+ if(!section) {
2384
+ return;
2385
+ }
2386
+
2387
+ let colCount = section.getColumnCount();
2388
+ for(let c = 0; c < colCount; c++) {
2389
+ let colDef = this._getColumnDef(c);
2390
+ let color = colDef["backgroundColor"] || "";
2391
+ this._applyCellsBackgroundColor(section, c, color);
2392
+ }
2393
+ };
2370
2394
 
2371
2395
  /** @public
2372
2396
  * @param {number} colIndex
@@ -5624,6 +5648,11 @@ Core.prototype._onRowCountChanged = function (e) {
5624
5648
 
5625
5649
  this._updateColumnSeparators();
5626
5650
  if(prevRowCount < newRowCount) {
5651
+ // Apply column background color
5652
+ let settings = this.getSectionSettings(section);
5653
+ if(settings.getType() !== "content") {
5654
+ this.applyColumnsBackgroundColor(section);
5655
+ }
5627
5656
  this._dispatch("rowAdded", e);
5628
5657
  } else if(prevRowCount > newRowCount) {
5629
5658
  this._dispatch("rowRemoved", e);
package/lib/grid/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import {Grid} from "./lib/efx-grid.js";
2
2
  export {Grid}
3
- window.EFX_GRID = { version: "6.0.129" };
3
+ window.EFX_GRID = { version: "6.0.130" };
@@ -12853,12 +12853,6 @@ const ROW_TYPES = {
12853
12853
  GROUP_MEMBER: "GROUP_MEMBER"
12854
12854
  };
12855
12855
 
12856
- /** @type {RegExp}
12857
- * @private
12858
- * @const
12859
- */
12860
- const ROW_ID_PATTERN = /^_[^_]+_$/;
12861
-
12862
12856
  /** @private
12863
12857
  * @function
12864
12858
  * @param {Object} obj
@@ -12903,6 +12897,11 @@ RowDefinition._runningId = 0;
12903
12897
  * @private
12904
12898
  */
12905
12899
  RowDefinition._childDataField = "CHILD_VALUES";
12900
+ /** @type {RegExp}
12901
+ * @private
12902
+ * @const
12903
+ */
12904
+ RowDefinition.ROW_ID_PATTERN = /^_[^_]+_$/;
12906
12905
  //#region Private Members
12907
12906
  /** @type {string}
12908
12907
  * @private
@@ -13058,7 +13057,7 @@ RowDefinition.prototype.initialize = function(rowOptions) {
13058
13057
  if(!this._autoGenerated) {
13059
13058
  let userRowId = rowOptions["rowId"];
13060
13059
  if(userRowId && typeof userRowId === "string") {
13061
- if(userRowId.match(ROW_ID_PATTERN)) {
13060
+ if(userRowId.match(RowDefinition.ROW_ID_PATTERN)) {
13062
13061
  console.warn("Please change the rowId format to avoid duplicated rows' id causing unexpected behavior.");
13063
13062
  } else {
13064
13063
  this._rowId = userRowId;
@@ -13709,12 +13708,7 @@ RowDefinition.prototype.isRealTimeRow = function() {
13709
13708
  * @return {boolean} If a subscription is made, return true.
13710
13709
  */
13711
13710
  RowDefinition.prototype.subscribeForUpdates = function(subs) {
13712
- if(subs) {
13713
- this._subs = subs;
13714
- } else {
13715
- subs = this._subs;
13716
- }
13717
- if(!subs) {
13711
+ if(!(subs || this._subs)) {
13718
13712
  return false;
13719
13713
  }
13720
13714
  if(!this.isRealTimeRow() && !this.getPermId()) {
@@ -13722,7 +13716,11 @@ RowDefinition.prototype.subscribeForUpdates = function(subs) {
13722
13716
  }
13723
13717
  // TODO: Check if the same subscription is being made.
13724
13718
  this.unsubscribeForUpdates();
13725
-
13719
+ if(subs) {
13720
+ this._subs = subs;
13721
+ } else {
13722
+ subs = this._subs;
13723
+ }
13726
13724
  if(this.isChain()) {
13727
13725
  let symbol = this._chainRic;
13728
13726
  if(!symbol){
@@ -13746,14 +13744,17 @@ RowDefinition.prototype.subscribeForUpdates = function(subs) {
13746
13744
  };
13747
13745
  /** Unsubscribe existing real-time data service. Static data is maintained
13748
13746
  * @public
13747
+ * @param {boolean=} keepData
13749
13748
  * @returns {null} Always return null
13750
13749
  */
13751
- RowDefinition.prototype.unsubscribeForUpdates = function() {
13750
+ RowDefinition.prototype.unsubscribeForUpdates = function(keepData) {
13752
13751
  if(this.isSubscribing()) { // Only normal real-time rows and chains have both subId and subscription object
13753
13752
  this._subs["removeSubscription"](this._subId);
13754
13753
  this._subId = "";
13755
- this.resetUpdates();
13756
- this.resetRowData(); // Real-time data is removed while static data is maintained
13754
+ if(!keepData) {
13755
+ this.resetUpdates();
13756
+ this.resetRowData(); // Real-time data is removed while static data is maintained
13757
+ }
13757
13758
  }
13758
13759
  return null;
13759
13760
  };
@@ -13972,8 +13973,9 @@ RowDefinition.prototype.addConstituent = function(ric) {
13972
13973
  /** Used to convert autogenerated row to regular real-time row
13973
13974
  * @public
13974
13975
  * @ignore
13976
+ * @param {string=} userRowId
13975
13977
  */
13976
- RowDefinition.prototype.toRealTimeRow = function() {
13978
+ RowDefinition.prototype.toRealTimeRow = function(userRowId) {
13977
13979
  if(!this.isConstituent()) {
13978
13980
  return; // Only a constituent can be converted to a real-time row
13979
13981
  }
@@ -13984,7 +13986,11 @@ RowDefinition.prototype.toRealTimeRow = function() {
13984
13986
  this._parent = null;
13985
13987
  this._depthLevel = 0;
13986
13988
 
13987
- this.resetRowData(); // WARNING: existing real-time data is lost after this line
13989
+ if(userRowId) {
13990
+ this._rowId = userRowId;
13991
+ this._userId = true;
13992
+ }
13993
+
13988
13994
  this.subscribeForUpdates(subs); // Static data remains intact
13989
13995
  };
13990
13996
 
@@ -13995,7 +14001,7 @@ RowDefinition.prototype.unlinkChain = function() {
13995
14001
  return;
13996
14002
  }
13997
14003
 
13998
- this.unsubscribeForUpdates(); // Static data remains intact
14004
+ this.unsubscribeForUpdates(true); // Static data remains intact
13999
14005
 
14000
14006
  let view = this._view;
14001
14007
  if(view) {
@@ -44996,6 +45002,14 @@ SortableTitlePlugin._proto = SortableTitlePlugin.prototype;
44996
45002
  * @description Fired only when a row will be removed through Grid's API and before occurring of the actual removal
44997
45003
  */
44998
45004
 
45005
+ /** @event Grid#beforeUnlinked
45006
+ * @description Trigger before unlinking a chain row.
45007
+ * @type {Object}
45008
+ * @property {RowDefinition} chain An row definition object of a chain row.
45009
+ * @property {boolean} collapsed Collapsing state of a chain row.
45010
+ * @property {Object} ridMap A map of constituent rics and row ids used to customize row ids.
45011
+ */
45012
+
44999
45013
  /** @private
45000
45014
  * @param {RowDefinition} rowDef
45001
45015
  * @return {Object}
@@ -45430,11 +45444,6 @@ Grid.prototype._topSection = true;
45430
45444
  * @private
45431
45445
  */
45432
45446
  Grid.prototype._focusingArgs = null;
45433
- /** @type {boolean}
45434
- * @private
45435
- */
45436
- Grid.prototype._unlinking = false;
45437
-
45438
45447
 
45439
45448
  /** @public
45440
45449
  */
@@ -47663,13 +47672,41 @@ Grid.prototype.unlinkChain = function(rowRef) {
47663
47672
  return;
47664
47673
  }
47665
47674
 
47666
- this._unlinking = true;
47667
-
47668
47675
  let childRowDefs = rowDef.getDescendants(); // TODO: Support nested child
47669
47676
  if(childRowDefs) {
47670
- if(rowDef.isChainExpanded()) {
47671
- for(let i = 0; i < childRowDefs.length; i++) {
47672
- childRowDefs[i].toRealTimeRow();
47677
+ let len = childRowDefs.length;
47678
+ let ridMap = {};
47679
+ for(let i = 0; i < len; i++) {
47680
+ ridMap[childRowDefs[i].getRic()] = "";
47681
+ }
47682
+ let collapsed = rowDef.isChainCollapsed();
47683
+ let args = {
47684
+ chain: rowDef,
47685
+ collapsed: collapsed,
47686
+ ridMap: ridMap
47687
+ };
47688
+ this._dispatch("beforeUnlinked", args);
47689
+
47690
+ if(!collapsed) {
47691
+ let rowIdChanged = false;
47692
+ let ridPair = {};
47693
+ for(let i = 0; i < len; i++) {
47694
+ let childRowDef = childRowDefs[i];
47695
+ let mappedRowId = ridMap[childRowDef.getRic()];
47696
+ if(mappedRowId) {
47697
+ if(mappedRowId.match(RowDefinition.ROW_ID_PATTERN)) {
47698
+ console.warn("Please change the rowId format to avoid duplicated rows' id causing unexpected behavior.");
47699
+ mappedRowId = "";
47700
+ } else {
47701
+ rowIdChanged = true;
47702
+ ridPair[childRowDef.getRowId()] = mappedRowId;
47703
+ }
47704
+ }
47705
+ childRowDef.toRealTimeRow(mappedRowId);
47706
+ }
47707
+ if(rowIdChanged) {
47708
+ this._dc.replaceRowIds(ridPair);
47709
+ this._dt.replaceRowIds(ridPair);
47673
47710
  }
47674
47711
  } else {
47675
47712
  this._removeConstituentRows(childRowDefs);
@@ -47677,8 +47714,6 @@ Grid.prototype.unlinkChain = function(rowRef) {
47677
47714
  }
47678
47715
 
47679
47716
  rowDef.unlinkChain();
47680
-
47681
- this._unlinking = false;
47682
47717
  };
47683
47718
 
47684
47719
  /** Alias to setRic
@@ -47992,6 +48027,15 @@ Grid.prototype.getAllRics = function() {
47992
48027
  Grid.prototype.hasRic = function() {
47993
48028
  return this._connector.hasRic();
47994
48029
  };
48030
+ /** Returns RIC of given row reference.
48031
+ * @public
48032
+ * @param {(string|number)=} rowRef
48033
+ * @return {string}
48034
+ */
48035
+ Grid.prototype.getRic = function(rowRef) {
48036
+ let rowDef = this.getRowDefinition(rowRef);
48037
+ return rowDef.getRic();
48038
+ };
47995
48039
  /** A shorthand to set row data based on index of the specified row. It is better to keep rowDefinition object for updating data directly as row index can be changed by sorting and filtering.
47996
48040
  * @public
47997
48041
  * @param {Grid~RowReference} rowRef