@refinitiv-ui/efx-grid 6.0.116 → 6.0.117

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.
@@ -621,7 +621,7 @@ Core.prototype._hasPendingRowChange = false;
621
621
  * @return {string}
622
622
  */
623
623
  Core.getVersion = function () {
624
- return "5.1.116";
624
+ return "5.1.117";
625
625
  };
626
626
  /** {@link ElementWrapper#dispose}
627
627
  * @override
@@ -5428,13 +5428,20 @@ Core.prototype.getColumnIndex = function (colRef) {
5428
5428
  return colRef;
5429
5429
  } else if(colRef) {
5430
5430
  let str = colRef;
5431
+ let indexByField = -1;
5431
5432
  let colCount = this.getColumnCount();
5432
5433
  for(let c = 0; c < colCount; ++c) {
5433
5434
  let colDef = this._getColumnDef(c);
5434
- if(str === colDef["id"] || str === colDef["field"]) {
5435
+ if(str === colDef["id"]){
5435
5436
  return c;
5436
5437
  }
5438
+ if(str === colDef["field"]) { // In case colId and field are the same, use colId first and field as a fallback
5439
+ if(indexByField < 0) {
5440
+ indexByField = c;
5441
+ }
5442
+ }
5437
5443
  }
5444
+ return indexByField;
5438
5445
  }
5439
5446
  return -1;
5440
5447
  };
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.116" };
3
+ window.EFX_GRID = { version: "6.0.117" };
@@ -106,7 +106,10 @@ RowSegmentingPlugin.prototype._predefinedColors = null;
106
106
  * @private
107
107
  */
108
108
  RowSegmentingPlugin._controlClass = "predefined-color-tag";
109
-
109
+ /** @type {Object}
110
+ * @private
111
+ */
112
+ RowSegmentingPlugin.prototype._collapsingMap = null;
110
113
 
111
114
  /** @public
112
115
  * @return {string}
@@ -171,45 +174,58 @@ RowSegmentingPlugin.prototype.requestSeparatorRefresh = function () {
171
174
  * @private
172
175
  */
173
176
  RowSegmentingPlugin.prototype._refreshSegmentSeparator = function () {
174
- var collapsedMapping = {};
177
+ var dv = this._getDataView();
178
+ if (!dv) { return; }
179
+
180
+ var collapsingMap = {};
181
+ if (this._collapsingMap) {
182
+ collapsingMap = this._collapsingMap;
183
+ this._collapsingMap = null;
184
+ }
185
+
186
+ var rowId, rowData, segmentId;
187
+ var dt = dv.getDataSource();
175
188
  var segmentRowIds = this.getSegmentIds() || [];
176
189
  var segmentCount = segmentRowIds.length;
177
- if(segmentCount){
178
- for(var index = 0; index < segmentCount; index++){
179
- var key = segmentRowIds[index];
180
- collapsedMapping[key] = this.isSegmentCollapsed(key);
190
+ if (segmentCount){
191
+ for(var s = 0; s < segmentCount; s++) {
192
+ rowId = segmentRowIds[s];
193
+ rowData = this._rowGetter(dt.getRowData(rowId));
194
+ segmentId = rowData[this._segmentIdField];
195
+ if (segmentId) {
196
+ if (collapsingMap[segmentId] == null) {
197
+ collapsingMap[segmentId] = this.isSegmentCollapsed(rowId);
198
+ }
199
+ }
181
200
  }
182
201
  }
183
202
 
184
- if(this._prevSegmentBySegmentId) { // Check only the segmentation set by the segment ID field and exclude the segment separator set by the runtime API using the setSegmentSeparator method
203
+ if (this._prevSegmentBySegmentId) { // Check only the segmentation set by the segment ID field and exclude the segment separator set by the runtime API using the setSegmentSeparator method
185
204
  this._prevSegmentBySegmentId = false;
186
205
  this.unsetAllSegmentSeparators();
206
+ // Note: if there are chains, their segmenting will be lost here and they cannot be restored
207
+ // because their children has no segment-id.
187
208
  }
188
- var dv = this._getDataView();
189
- if(dv) {
190
- var dt = dv.getDataSource();
191
- var rowIds = dt.getAllRowIds();
192
- var rowCount = rowIds.length;
193
- var separatorMapping = {};
194
- for (var i = 0; i < rowCount; i++) {
195
- var rowId = rowIds[i];
196
- var rowData = this._rowGetter(dt.getRowData(rowId));
197
- var segmentId = rowData[this._segmentIdField];
198
- // TODO: supports collapsed and expanded for save/restore
199
-
200
- if(segmentId != null) {
201
- if(separatorMapping[segmentId] != null ) {
202
- this.addSegmentChild(separatorMapping[segmentId], rowId);
203
- } else {
204
- separatorMapping[segmentId] = rowId;
205
- this.setSegmentSeparator(rowId);
206
- }
207
- this._prevSegmentBySegmentId = true;
208
209
 
209
- if(collapsedMapping[rowId]){
210
- this.collapseSegment(rowId, collapsedMapping[rowId]);
210
+ var rowIds = dt.getAllRowIds();
211
+ var rowCount = rowIds.length;
212
+ var separatorMap = {};
213
+ for(var i = 0; i < rowCount; i++) {
214
+ rowId = rowIds[i];
215
+ rowData = this._rowGetter(dt.getRowData(rowId));
216
+ segmentId = rowData[this._segmentIdField];
217
+
218
+ if (segmentId != null) {
219
+ if (separatorMap[segmentId] != null ) {
220
+ this.addSegmentChild(separatorMap[segmentId], rowId);
221
+ } else {
222
+ separatorMap[segmentId] = rowId;
223
+ this.setSegmentSeparator(rowId);
224
+ if (collapsingMap[segmentId] != null) {
225
+ this.collapseSegment(rowId, collapsingMap[segmentId]);
211
226
  }
212
227
  }
228
+ this._prevSegmentBySegmentId = true;
213
229
  }
214
230
  }
215
231
  };
@@ -275,6 +291,29 @@ RowSegmentingPlugin.prototype.config = function (options) {
275
291
  this.addListener(option, "clicked");
276
292
  this.addListener(option, "segmentSeparatorBinding");
277
293
  this.addListener(option, "nonSegmentSeparatorBinding");
294
+
295
+ // Collect collapsing states from configuration
296
+ var collapsingMap = {};
297
+ var dirty = false;
298
+ var rows = options.rows;
299
+ if (rows && rows.length) {
300
+ var len = rows.length;
301
+ for (var i = 0; i < len; i++) {
302
+ var row = rows[i];
303
+ var segmentId = row.values ? row.values[this._segmentIdField] : null;
304
+ if (segmentId && collapsingMap[segmentId] == null) {
305
+ if(row["collapsed"] != null) {
306
+ dirty = true;
307
+ collapsingMap[segmentId] = row["collapsed"] ? true : false;
308
+ }
309
+ }
310
+ }
311
+ }
312
+
313
+ if (dirty) {
314
+ this._collapsingMap = collapsingMap;
315
+ }
316
+
278
317
  this.requestSeparatorRefresh();
279
318
  };
280
319
 
@@ -335,6 +374,10 @@ RowSegmentingPlugin.prototype.getRowConfigObject = function (rowData, rowId) {
335
374
  }
336
375
 
337
376
  if(this.isSegmentSeparator(rowId)) {
377
+ if(obj["collapsed"] == null) { // Avoid overriding value from real-time grid
378
+ obj["collapsed"] = this.isSegmentCollapsed(rowId);
379
+ }
380
+
338
381
  if(!obj.values) {
339
382
  obj.values = {};
340
383
  }