@refinitiv-ui/efx-grid 6.0.158 → 6.0.160

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.
@@ -13038,6 +13038,12 @@ let Segment = function(rid, sharedObj) {
13038
13038
  };
13039
13039
  es6_Ext.inherits(Segment, es6_EventDispatcher);
13040
13040
 
13041
+ /** @public
13042
+ * @type {string}
13043
+ * @constant
13044
+ */
13045
+ const UNCATEGORY = "Uncategorized";
13046
+
13041
13047
  /** @private
13042
13048
  * @function
13043
13049
  * @param {string} a
@@ -13045,10 +13051,10 @@ es6_Ext.inherits(Segment, es6_EventDispatcher);
13045
13051
  * @return {number}
13046
13052
  */
13047
13053
  Segment._subSegSortLogic = function(a, b) {
13048
- if(a === "Uncategorized") {
13054
+ if(a === UNCATEGORY) {
13049
13055
  return 1;
13050
13056
  }
13051
- if(b === "Uncategorized") {
13057
+ if(b === UNCATEGORY) {
13052
13058
  return -1;
13053
13059
  }
13054
13060
 
@@ -13525,7 +13531,7 @@ Segment.prototype.classify = function(rows) {
13525
13531
 
13526
13532
  sharedObj.childToSegment[rid] = this._rid; // Relocate child in case of it has been moved to a non existence group
13527
13533
 
13528
- segmentName = "Uncategorized";
13534
+ segmentName = UNCATEGORY;
13529
13535
  if(val || val === 0 || val === false) { // Check for null, undefined, "", and NaN value
13530
13536
  segmentName = val + "";
13531
13537
  }
@@ -13601,13 +13607,6 @@ Segment.prototype.classify = function(rows) {
13601
13607
  }
13602
13608
  }
13603
13609
 
13604
- // Collecting all subsegments including all descendants and reassigning segment order.
13605
- if(rootSegment && this._subSegDef) {
13606
- if(segmentCount) {
13607
- this.calcSubSegmentOrder(0);
13608
- }
13609
- // this._subSegDef.classifierChanged = false;
13610
- }
13611
13610
  return true;
13612
13611
  };
13613
13612
  /** SubSegment implies being classified
@@ -13675,65 +13674,68 @@ Segment.prototype.getAllSubSegments = function(out_ary) {
13675
13674
  /** This method sets order, last order, and depth to entire tree structure in the segment, including the segment itself
13676
13675
  * @public
13677
13676
  * @param {number} counter
13678
- * @return {number}
13677
+ * @param {number} rootOrder
13678
+ * @param {Object} ridMap Row id map that stores row order of the entire tree
13679
+ * @return {number} Last order of the segment
13679
13680
  */
13680
- Segment.prototype.updateTreeStructure = function(counter) {
13681
+ Segment.prototype.updateTreeStructure = function(counter, rootOrder, ridMap) {
13681
13682
  if(!counter) {
13682
13683
  counter = 0;
13683
13684
  if(!this._subSegment) { // Subsegment's depth cannot be reset back to 0
13684
13685
  this._depth = 0; // WARNING: this assumes counter at 0 is the root segment
13685
13686
  }
13686
13687
  }
13687
- if(this.hasSubSegments()) {
13688
- return this.setLastOrder(counter); // Sub segments has already been calculated
13688
+ if(!rootOrder) {
13689
+ rootOrder = 0;
13689
13690
  }
13690
- let segmentSeparators = this._shared.segments;
13691
- let childCount = this._childIds.length;
13692
- let prevSeg = null;
13693
- for(let i = 0; i < childCount; ++i) {
13694
- let rid = this._childIds[i];
13695
- let segment = segmentSeparators[rid];
13696
- let segmentId = (segment) ? segment.getId() : "Uncategorized";
13697
- if(prevSeg !== segmentId) {
13698
- ++counter; // 0 become 1
13699
- prevSeg = segmentId;
13691
+ if(!ridMap) {
13692
+ ridMap = {};
13693
+ }
13694
+
13695
+ let i;
13696
+ let segmentNames = this._subSegNames;
13697
+ let subSegmentCount = segmentNames ? segmentNames.length : 0;
13698
+ if(subSegmentCount) { // Classified segment
13699
+ let segmentMap = this._subSegMap;
13700
+ for(i = 0; i < subSegmentCount; ++i) {
13701
+ let subSegment = segmentMap[segmentNames[i]];
13702
+ ++counter;
13703
+ ridMap[subSegment.getId()] = rootOrder + counter;
13704
+ subSegment.setOrder(counter);
13705
+ counter = subSegment.updateTreeStructure(counter, rootOrder, ridMap);
13700
13706
  }
13701
- if(segment) {
13702
- segment._depth = this._depth + 1;
13703
- segment.setOrder(counter);
13704
- counter = segment.updateTreeStructure(counter);
13707
+ } else {
13708
+ let childIds = this._childIds;
13709
+ let childCount = childIds.length;
13710
+ let segmentSeparators = this._shared.segments;
13711
+ let prevSeg = "";
13712
+ for(i = 0; i < childCount; ++i) {
13713
+ let childId = childIds[i];
13714
+ let childSegment = segmentSeparators[childId];
13715
+ let segmentId = (childSegment) ? childSegment.getId() : UNCATEGORY;
13716
+ if(prevSeg !== segmentId) {
13717
+ ++counter;
13718
+ prevSeg = segmentId;
13719
+ }
13720
+ ridMap[childId] = rootOrder + counter;
13721
+ if(childSegment) {
13722
+ childSegment._depth = this._depth + 1;
13723
+ childSegment.setOrder(counter);
13724
+ counter = childSegment.updateTreeStructure(counter, rootOrder, ridMap);
13725
+ }
13705
13726
  }
13706
13727
  }
13707
13728
 
13708
13729
  return this.setLastOrder(counter);
13709
13730
  };
13710
- /** @public
13731
+ /** Deprecated.
13732
+ * @ignore
13733
+ * @public
13734
+ * @function
13711
13735
  * @param {number} counter
13712
13736
  * @return {number}
13713
13737
  */
13714
- Segment.prototype.calcSubSegmentOrder = function(counter) {
13715
- if(!this.hasSubSegments()) {
13716
- return this.setLastOrder(counter);
13717
- }
13718
-
13719
- let segmentMap = this._subSegMap;
13720
- let childCount = this._subSegNames.length;
13721
- let prevSeg = null;
13722
- for(let i = 0; i < childCount; ++i) {
13723
- let segmentName = this._subSegNames[i];
13724
- let segment = segmentMap[segmentName];
13725
- let segmentId = (segment) ? segment.getId() : "Uncategorized";
13726
- if(prevSeg !== segmentId) {
13727
- ++counter; // 0 become 1
13728
- prevSeg = segmentId;
13729
- }
13730
- if(segment) {
13731
- segment.setOrder(counter);
13732
- counter = segment.calcSubSegmentOrder(counter);
13733
- }
13734
- }
13735
- return this.setLastOrder(counter);
13736
- };
13738
+ Segment.prototype.calcSubSegmentOrder = Segment.prototype.updateTreeStructure;
13737
13739
  /** @public
13738
13740
  * @return {number}
13739
13741
  */
@@ -13783,14 +13785,6 @@ Segment.prototype.getSubSegmentName = function(row) {
13783
13785
  return this._subSegName;
13784
13786
  };
13785
13787
  /**
13786
- * @private
13787
- * @param {!Segment} segment
13788
- * @returns {string}
13789
- */
13790
- let _toSegmentId = function(segment) {
13791
- return segment.getId();
13792
- };
13793
- /**
13794
13788
  * @public
13795
13789
  * @param {!Function} comparer
13796
13790
  * @returns {boolean} Returns true if there is any change
@@ -13800,26 +13794,17 @@ Segment.prototype.sortSegments = function(comparer) {
13800
13794
  return false;
13801
13795
  }
13802
13796
 
13803
- let segmentList = [];
13804
- let rids = [];
13805
13797
  let childIds = this._childIds;
13806
13798
  let childCount = childIds.length;
13807
13799
  let segments = this._shared.segments;
13808
13800
  for(let i = 0; i < childCount; ++i) {
13809
- let childId = childIds[i];
13810
- let childSegment = segments[childId];
13811
- if(childSegment) {
13812
- segmentList.push(childSegment);
13813
- } else {
13814
- rids.push(childId);
13801
+ if(segments[childIds[i]]) {
13802
+ this._childIds.sort(comparer); // Perform segment sorting only if children have at least one segment
13803
+ return true;
13815
13804
  }
13816
13805
  }
13817
- if(segmentList.length < 2) {
13818
- return false;
13819
- }
13820
- segmentList.sort(comparer);
13821
- this._childIds = rids.concat(segmentList.map(_toSegmentId));
13822
- return true;
13806
+
13807
+ return false;
13823
13808
  };
13824
13809
  /** Get segment id and ids of children, including nested segments, but excluding sub segments
13825
13810
  * @public
@@ -13933,28 +13918,15 @@ Segment.prototype.getCollapsingStates = function(objMap, parentState) {
13933
13918
  return dirty;
13934
13919
  };
13935
13920
 
13936
- /** @private
13937
- * @return {number}
13938
- */
13939
- Segment.prototype._getOrder = function() {
13940
- return this._order * 10000;
13941
- };
13942
- /** @private
13943
- * @return {number}
13944
- */
13945
- Segment.prototype._getLastOrder = function() {
13946
- return this._getOrder() + this._offsetOrder;
13947
- };
13948
13921
  /** @public
13949
13922
  * @return {number}
13950
13923
  */
13951
13924
  Segment.prototype.getOrder = function() {
13952
13925
  let ancestor = this.getFirstAncestor();
13953
13926
  if(ancestor) {
13954
- // WARNING: this._order cannot be greater than 9999
13955
- return ancestor._getOrder() + this._order;
13927
+ return ancestor._order + this._order;
13956
13928
  }
13957
- return this._getOrder();
13929
+ return this._order; // This is root order
13958
13930
  };
13959
13931
  /** Get the last (highest) order from the entire tree regardless of the current position segment in the hierachy
13960
13932
  * @public
@@ -13963,10 +13935,9 @@ Segment.prototype.getOrder = function() {
13963
13935
  Segment.prototype.getLastOrder = function() {
13964
13936
  let ancestor = this.getFirstAncestor();
13965
13937
  if(ancestor) {
13966
- // WARNING: this._order cannot be greater than 9999
13967
- return ancestor._getLastOrder();
13938
+ return ancestor.getLastOrder();
13968
13939
  }
13969
- return this._getLastOrder();
13940
+ return this._order + this._offsetOrder; // This is root last order
13970
13941
  };
13971
13942
  /** @public
13972
13943
  * @param {number} val
@@ -13974,12 +13945,13 @@ Segment.prototype.getLastOrder = function() {
13974
13945
  Segment.prototype.setOrder = function(val) {
13975
13946
  this._order = val;
13976
13947
  };
13977
- /** @public
13948
+ /** WARNING: This actually sets offset from the starting order
13949
+ * @public
13978
13950
  * @param {number} val
13979
13951
  * @returns {number} Returns the number set
13980
13952
  */
13981
13953
  Segment.prototype.setLastOrder = function(val) {
13982
- return (this._offsetOrder = val);
13954
+ return (this._offsetOrder = val); // WARNING: this._offsetOrder cannot be greater than 9999
13983
13955
  };
13984
13956
 
13985
13957
  /** @private
@@ -14047,7 +14019,7 @@ Segment.prototype.log = function(lines, tabLevel) {
14047
14019
  };
14048
14020
 
14049
14021
 
14050
- /* harmony default export */ const data_Segment = (Segment);
14022
+ /* harmony default export */ const data_Segment = ((/* unused pure expression or super */ null && (Segment)));
14051
14023
 
14052
14024
 
14053
14025
  ;// CONCATENATED MODULE: ./src/js/data/SegmentCollection.js
@@ -14095,7 +14067,7 @@ SegmentCollection.prototype._shared;
14095
14067
  /** @type {Array.<Segment>}
14096
14068
  * @private
14097
14069
  */
14098
- SegmentCollection.prototype._segmentList = null; // Array of main segments
14070
+ SegmentCollection.prototype._segmentList = null; // Array of main/root segments
14099
14071
  /** @type {Array.<Segment>}
14100
14072
  * @private
14101
14073
  */
@@ -14112,6 +14084,10 @@ SegmentCollection.prototype._classification = false;
14112
14084
  * @private
14113
14085
  */
14114
14086
  SegmentCollection.prototype._classifierChanged = false;
14087
+ /** @type {Object.<string, number>}
14088
+ * @private
14089
+ */
14090
+ SegmentCollection.prototype._rowOrders = null;
14115
14091
 
14116
14092
  /** @public
14117
14093
  */
@@ -14119,7 +14095,7 @@ SegmentCollection.prototype.dispose = function() {
14119
14095
  this.removeAllSegments();
14120
14096
  this.removeAllEventListeners();
14121
14097
  this._collapsedRids = null;
14122
- this._segmentList = this._insertionList = this._removalList = null;
14098
+ this._segmentList = this._rowOrders = this._insertionList = this._removalList = null;
14123
14099
  };
14124
14100
  /** @public
14125
14101
  * @param {string} rid
@@ -14128,11 +14104,11 @@ SegmentCollection.prototype.dispose = function() {
14128
14104
  */
14129
14105
  SegmentCollection.prototype.addSegment = function(rid, childRids) {
14130
14106
  if(rid && !this._segments[rid]) {
14131
- let segment = this._segments[rid] = new data_Segment(rid, this._shared);
14107
+ let segment = this._segments[rid] = new Segment(rid, this._shared);
14132
14108
  segment.addEventListener("subSegmentAdded", this._onSubSegmentAdded);
14133
14109
  segment.addEventListener("subSegmentRemoved", this._onSubSegmentRemoved);
14134
14110
  ++this._segmentCount;
14135
- this._segmentList = null; // order could be changed
14111
+ this.invalidateSegmentOrder(); // order could be changed
14136
14112
 
14137
14113
  if(childRids && childRids.length) {
14138
14114
  segment.addChildren(childRids);
@@ -14208,6 +14184,7 @@ SegmentCollection.prototype.removeSegment = function(rid) {
14208
14184
 
14209
14185
  delete this._segments[rid]; // Slow
14210
14186
  --this._segmentCount;
14187
+ this.invalidateSegmentOrder();
14211
14188
  return true;
14212
14189
  };
14213
14190
  /** @public
@@ -14220,7 +14197,7 @@ SegmentCollection.prototype.removeAllSegments = function() {
14220
14197
  }
14221
14198
  this._segments = {};
14222
14199
  this._segmentCount = 0;
14223
- this._segmentList = null;
14200
+ this._segmentList = this._rowOrders = null;
14224
14201
  this._shared.segments = this._segments;
14225
14202
  this._shared.childToSegment = {};
14226
14203
 
@@ -14281,6 +14258,7 @@ SegmentCollection.prototype.sortSegments = function(comparer) {
14281
14258
  }
14282
14259
  }
14283
14260
  rootSegments.sort(comparer);
14261
+ this.invalidateSegmentOrder();
14284
14262
  return rootSegments;
14285
14263
  };
14286
14264
 
@@ -14376,28 +14354,14 @@ SegmentCollection.prototype.getCollapsedRows = function() {
14376
14354
  return this._collapsedRids;
14377
14355
  };
14378
14356
 
14379
- /** Invalidate segment order cache, if the given row id is a segment separator
14380
- * @private
14381
- * @param {string|Array.<string>} segmentIds
14357
+ /** Invalidate segment order cache
14358
+ * @public
14382
14359
  * @returns {boolean} Returns true if there is any change
14383
14360
  */
14384
- SegmentCollection.prototype._invalidateSegmentOrder = function(segmentIds) {
14361
+ SegmentCollection.prototype.invalidateSegmentOrder = function() {
14385
14362
  if(this._segmentList) {
14386
- if(typeof segmentIds === "string") {
14387
- if(this._segments[segmentIds]) {
14388
- this._segmentList = null;
14389
- return true;
14390
- }
14391
- } else if(Array.isArray(segmentIds)) {
14392
- let len = segmentIds.length;
14393
- for(let i = 0; i < len; ++i) {
14394
- let segmentId = segmentIds[i];
14395
- if(this._segments[segmentId]) {
14396
- this._segmentList = null;
14397
- return true;
14398
- }
14399
- }
14400
- }
14363
+ this._segmentList = this._rowOrders = null;
14364
+ return true;
14401
14365
  }
14402
14366
  return false;
14403
14367
  };
@@ -14411,7 +14375,7 @@ SegmentCollection.prototype.addSegmentChild = function(segmentId, rid, dataId) {
14411
14375
  let segment = this._segments[segmentId];
14412
14376
  if(segment && !segment.isSubSegment()) {
14413
14377
  // If a segment becomes a child of other segment, then the segment order needs to be recalculated
14414
- this._invalidateSegmentOrder(rid);
14378
+ this.invalidateSegmentOrder();
14415
14379
  return segment.addChild(rid, dataId);
14416
14380
  }
14417
14381
  return false;
@@ -14426,7 +14390,7 @@ SegmentCollection.prototype.addSegmentChildren = function(segmentId, rids, dataI
14426
14390
  let segment = this._segments[segmentId];
14427
14391
  if(segment && !segment.isSubSegment()) {
14428
14392
  // If a segment becomes a child of other segment, then the segment order needs to be recalculated
14429
- this._invalidateSegmentOrder(rids);
14393
+ this.invalidateSegmentOrder();
14430
14394
  return segment.addChildren(rids, dataIds);
14431
14395
  }
14432
14396
  return false;
@@ -14452,7 +14416,7 @@ SegmentCollection.prototype.containsSegmentChild = function(segmentId, rid) {
14452
14416
  SegmentCollection.prototype.removeSegmentChild = function(segmentId, rid) {
14453
14417
  let segment = this._segments[segmentId];
14454
14418
  if(segment) {
14455
- this._invalidateSegmentOrder(rid);
14419
+ this.invalidateSegmentOrder();
14456
14420
  return segment.removeChild(rid);
14457
14421
  }
14458
14422
  return false;
@@ -14465,7 +14429,7 @@ SegmentCollection.prototype.removeSegmentChild = function(segmentId, rid) {
14465
14429
  SegmentCollection.prototype.removeSegmentChildren = function(segmentId, rids) {
14466
14430
  let segment = this._segments[segmentId];
14467
14431
  if(segment) {
14468
- this._invalidateSegmentOrder(rids);
14432
+ this.invalidateSegmentOrder();
14469
14433
  return segment.removeChildren(rids);
14470
14434
  }
14471
14435
  return false;
@@ -14485,7 +14449,7 @@ SegmentCollection.prototype.removeAllSegmentChildren = function() {
14485
14449
  }
14486
14450
 
14487
14451
  if(dirty) {
14488
- this._segmentList = null; // WARNING: not optimized
14452
+ this.invalidateSegmentOrder();
14489
14453
  this.classify(null);
14490
14454
  }
14491
14455
 
@@ -14515,6 +14479,7 @@ SegmentCollection.prototype.fillSegment = function(segmentId, rids) {
14515
14479
  }
14516
14480
  curSegment.addChild(rid);
14517
14481
  }
14482
+ this.invalidateSegmentOrder();
14518
14483
  }
14519
14484
  }
14520
14485
  };
@@ -14540,8 +14505,19 @@ SegmentCollection.prototype.fillSegments = function(rids) {
14540
14505
  change = true;
14541
14506
  }
14542
14507
  }
14508
+ if(change) {
14509
+ this.invalidateSegmentOrder();
14510
+ }
14543
14511
  return change;
14544
14512
  };
14513
+
14514
+ /** The number represent maximum nested segments that can be created in a single segment
14515
+ * @private
14516
+ * @type {number}
14517
+ * @constant
14518
+ */
14519
+ const SEGMENT_STEP = 10000;
14520
+
14545
14521
  /** @public
14546
14522
  * @param {Array.<string>} rids
14547
14523
  * @param {boolean=} useCache=false If this is true, skip the calculation when there is already a cache for segment order
@@ -14557,21 +14533,29 @@ SegmentCollection.prototype.calcSegmentOrder = function(rids, useCache) {
14557
14533
  segmentList = this._segmentList = [];
14558
14534
  }
14559
14535
 
14560
- let ridCount = rids ? rids.length : 0;
14536
+ this._rowOrders = {};
14537
+ let rowOrders = this._rowOrders;
14561
14538
  let segmentSeparators = this._segments;
14562
- let segmentCount = this._segmentCount;
14539
+ let childToSegmentId = this._shared.childToSegment;
14540
+ let prevSeg = UNCATEGORY;
14541
+ let ridCount = rids ? rids.length : 0;
14563
14542
  let order = 0;
14564
14543
  for(let i = 0; i < ridCount; ++i) {
14565
14544
  let rid = rids[i];
14566
- let segment = segmentSeparators[rid];
14567
- if(segment) {
14568
- if(segment.isRootSegment()) {
14569
- this._segmentList.push(segment);
14570
- segment.setOrder(++order); // WARNING: Segments and sub segments start with 1
14571
- segment.updateTreeStructure(0);
14545
+ if(!childToSegmentId[rid]) {
14546
+ let segment = segmentSeparators[rid];
14547
+ let segmentId = (segment) ? segment.getId() : UNCATEGORY;
14548
+ if(prevSeg !== segmentId) {
14549
+ ++order; // WARNING: Segments and sub segments start with 1
14550
+ prevSeg = segmentId;
14572
14551
  }
14573
- if(--segmentCount <= 0) {
14574
- break;
14552
+
14553
+ let rootOrder = order * SEGMENT_STEP;
14554
+ rowOrders[rid] = rootOrder;
14555
+ if(segment) {
14556
+ this._segmentList.push(segment);
14557
+ segment.setOrder(rootOrder);
14558
+ segment.updateTreeStructure(0, rootOrder, rowOrders);
14575
14559
  }
14576
14560
  }
14577
14561
  }
@@ -14580,57 +14564,33 @@ SegmentCollection.prototype.calcSegmentOrder = function(rids, useCache) {
14580
14564
  * @param {!Array.<string>} rids Array of row ids
14581
14565
  * @param {boolean=} partial Indicating that the given ids are not the whole list
14582
14566
  * @return {Array.<number>} Returns Array of segment values, if there are at least one segment, otherwise returns null
14583
- */ //
14567
+ */
14584
14568
  SegmentCollection.prototype.getSegmentValues = function(rids, partial) {
14585
14569
  let rowCount = rids ? rids.length : 0;
14586
14570
  if(!rowCount) {
14587
14571
  return null;
14588
14572
  }
14589
- let segmentSeparators = this._segments;
14590
- let childToSegmentId = this._shared.childToSegment;
14591
- let curSegment = null;
14592
- let prevSegment = null;
14573
+ let rowOrders = this._rowOrders;
14574
+ if(!rowOrders) { // calcSegmentOrder has not been called (no cache detected)
14575
+ return null;
14576
+ }
14577
+
14593
14578
  let segmentValues = new Array(rowCount);
14594
- let segmentVal = 0;
14595
14579
  let highestVal = 0;
14596
- let offset = 0;
14597
14580
  for(let r = 0; r < rowCount; ++r) {
14598
14581
  let rid = rids[r];
14599
- curSegment = segmentSeparators[rid];
14600
- if(curSegment) { // segment separator
14601
- segmentVal = curSegment.getOrder() * 100;
14602
- offset = 0;
14603
- if(curSegment.isRootSegment()) {
14604
- if(prevSegment !== curSegment) {
14605
- prevSegment = curSegment;
14606
- highestVal = curSegment.getLastOrder() * 100;
14607
- }
14582
+ let segmentVal = rowOrders[rid];
14583
+ if(segmentVal != null) {
14584
+ if(highestVal < segmentVal) {
14585
+ highestVal = segmentVal;
14608
14586
  }
14609
14587
  } else {
14610
- let parentId = childToSegmentId[rid];
14611
- if(parentId) { // segment member
14612
- curSegment = segmentSeparators[parentId];
14613
- segmentVal = curSegment.getOrder() * 100;
14614
- offset = 1;
14615
- if(partial) { // This fixes the out of order sub segment
14616
- highestVal = curSegment.getLastOrder() * 100;
14617
- }
14618
- } else { // row outside of segments
14619
- if(highestVal) {
14620
- if(segmentVal < highestVal) {
14621
- segmentVal = highestVal;
14622
- }
14623
- offset = 10;
14624
- } else {
14625
- segmentVal = offset = 0;
14626
- }
14627
- }
14588
+ segmentVal = highestVal ? highestVal + SEGMENT_STEP : 0;
14628
14589
  }
14629
-
14630
- segmentValues[r] = segmentVal + offset;
14590
+ segmentValues[r] = segmentVal;
14631
14591
  }
14632
14592
 
14633
- return prevSegment ? segmentValues : null;
14593
+ return highestVal ? segmentValues : null;
14634
14594
  };
14635
14595
  /** @public
14636
14596
  * @return {string}
@@ -14719,6 +14679,7 @@ SegmentCollection.prototype.classify = function(rows) {
14719
14679
  }
14720
14680
  }
14721
14681
  if(this._insertionList.length || this._removalList.length) {
14682
+ this.invalidateSegmentOrder();
14722
14683
  this._dispatch("subSegmentChanged", {
14723
14684
  "insertionList": this._insertionList,
14724
14685
  "removalList": this._removalList
@@ -14875,7 +14836,6 @@ DataTable.prototype._classifyingTimer = 0;
14875
14836
  */
14876
14837
  DataTable.prototype._segmentDefaultCollapsing = false;
14877
14838
 
14878
-
14879
14839
  /** @typedef {Function} DataTable~SortLogic
14880
14840
  * @description SortLogic function is used for comparison between two values during sorting. <br>
14881
14841
  * The function should return:<br>
@@ -14985,6 +14945,7 @@ DataTable.prototype.getPreviousData = function(rid, cid) {
14985
14945
  return null;
14986
14946
  };
14987
14947
 
14948
+
14988
14949
  /** Set data to individual cell
14989
14950
  * @override
14990
14951
  * @param {string} rid Row Id
@@ -15065,7 +15026,10 @@ DataTable.prototype.setRowData = function(rid, values, eventArg) { // Data chang
15065
15026
  this._rids.push(rid);
15066
15027
  } else {
15067
15028
  this._rids.splice(rowIndex, 0, rid);
15068
- segmentChanged = !this._isLastSegment(rowIndex);
15029
+ if(this._segments) { // for no sorting case
15030
+ this._segments.invalidateSegmentOrder();
15031
+ }
15032
+ segmentChanged = !this._isLastSegment(rowIndex); // This is slow. Check if this is required
15069
15033
  }
15070
15034
  } else {
15071
15035
  this._rids.push(rid);
@@ -15510,7 +15474,7 @@ DataTable.prototype.moveRow = function(fromIndex, toIndex, suppressEvent) {
15510
15474
 
15511
15475
  if(output) {
15512
15476
  if(this._segments) {
15513
- this._segments.calcSegmentOrder(this._rids);
15477
+ this._segments.invalidateSegmentOrder();
15514
15478
  this._sort(null); // Reorder segment members
15515
15479
  }
15516
15480
  this._dispatchPositionChange(suppressEvent);
@@ -15767,6 +15731,9 @@ DataTable.prototype.freeze = function(bool) {
15767
15731
  let prevState = this._frozen;
15768
15732
  if(prevState !== bool) {
15769
15733
  this._frozen = bool;
15734
+ if(!bool && this._segments) { // for no sorting case
15735
+ this._segments.invalidateSegmentOrder();
15736
+ }
15770
15737
  this._autoFillSegments();
15771
15738
  this.dispatchGlobalChange();
15772
15739
  }
@@ -15833,9 +15800,6 @@ DataTable.prototype.setSegmentSeparators = function(rids, enabled) {
15833
15800
  }
15834
15801
  }
15835
15802
  }
15836
- if (segmentAdded) {
15837
- this._segments.calcSegmentOrder(this._rids);
15838
- }
15839
15803
  let changed = segmentAdded || segmentRemoved;
15840
15804
  if(changed && this._needFiring()) {
15841
15805
  this.dispatchGlobalChange();
@@ -15863,7 +15827,6 @@ DataTable.prototype.setSegmentSeparator = function(rid, options) {
15863
15827
  }
15864
15828
  let children = (options && options["children"]) ? options["children"] : null;
15865
15829
  if(this._segments.addSegment(rid, children)) {
15866
- this._segments.calcSegmentOrder(this._rids);
15867
15830
  change = true;
15868
15831
  }
15869
15832
  } else if(this._segments) { // Remove the separator
@@ -15988,6 +15951,7 @@ DataTable.prototype.getSegmentParentRowId = function(rid) {
15988
15951
  */
15989
15952
  DataTable.prototype.getSegmentValues = function(rids, partial) {
15990
15953
  if(this._segments) {
15954
+ this._segments.calcSegmentOrder(this._rids, true); // use cache
15991
15955
  return this._segments.getSegmentValues(rids || this._rids, partial);
15992
15956
  }
15993
15957
  return null;
@@ -16065,9 +16029,6 @@ DataTable.prototype.fillSegments = function() {
16065
16029
  * @param {boolean=} adding This indicates that segment is changed by adding a new child
16066
16030
  */
16067
16031
  DataTable.prototype._onSegmentChildChanged = function(adding) {
16068
- if(this._segments) {
16069
- this._segments.calcSegmentOrder(this._rids, true);
16070
- }
16071
16032
  if(adding !== false) {
16072
16033
  this._sort(null);
16073
16034
  }
@@ -16256,7 +16217,6 @@ DataTable.prototype.sortSegments = function (compare) {
16256
16217
  return false;
16257
16218
  }
16258
16219
  if(typeof compare !== "function") {
16259
- this._segments.calcSegmentOrder(this._rids);
16260
16220
  return false;
16261
16221
  }
16262
16222
 
@@ -16291,7 +16251,6 @@ DataTable.prototype.sortSegments = function (compare) {
16291
16251
  }
16292
16252
 
16293
16253
  if(dirty) {
16294
- this._segments.calcSegmentOrder(rids);
16295
16254
  this._sort(null);
16296
16255
  this._dispatchPositionChange();
16297
16256
  }
@@ -16299,18 +16258,34 @@ DataTable.prototype.sortSegments = function (compare) {
16299
16258
  };
16300
16259
  /** Sort all of existing segments by given compare function
16301
16260
  * @private
16302
- * @param {tr.Segment} segmentA
16303
- * @param {tr.Segment} segmentB
16261
+ * @param {*} rowA
16262
+ * @param {*} rowB
16304
16263
  * @return {number}
16305
16264
  */
16306
- DataTable.prototype._bySegmentSeparator = function (segmentA, segmentB) {
16265
+ DataTable.prototype._bySegmentSeparator = function (rowA, rowB) {
16307
16266
  return /** @type{number} */(this._userSegmentComparer(
16308
- this.getRowData(segmentA.getId()),
16309
- this.getRowData(segmentB.getId()),
16267
+ this._getRowDataFromSegment(rowA),
16268
+ this._getRowDataFromSegment(rowB),
16310
16269
  this._segmentSortOrder,
16311
16270
  this._segmentSortContext
16312
16271
  ));
16313
16272
  };
16273
+ /** Get row data from either Segment or row id
16274
+ * @private
16275
+ * @param {*} obj
16276
+ * @return {Object}
16277
+ */
16278
+ DataTable.prototype._getRowDataFromSegment = function (obj) {
16279
+ var rowData = null;
16280
+ if(obj) {
16281
+ if(typeof obj == "string") {
16282
+ rowData = this.getRowData(obj);
16283
+ } else if(obj.getId) {
16284
+ rowData = this.getRowData(obj.getId());
16285
+ }
16286
+ }
16287
+ return rowData;
16288
+ };
16314
16289
 
16315
16290
  /** A data source to be used with segment classification
16316
16291
  * @public
@@ -19436,6 +19411,7 @@ DataView.prototype.getAllRowData = function() {
19436
19411
  return this.getMultipleRowData(this.getAllRowIds(true));
19437
19412
  };
19438
19413
 
19414
+
19439
19415
  /** @public
19440
19416
  * @param {string} rid
19441
19417
  * @param {string} cid
@@ -26287,7 +26263,7 @@ Core_Core.prototype._hasPendingRowChange = false;
26287
26263
  * @return {string}
26288
26264
  */
26289
26265
  Core_Core.getVersion = function () {
26290
- return "5.1.140";
26266
+ return "5.2.2";
26291
26267
  };
26292
26268
  /** {@link ElementWrapper#dispose}
26293
26269
  * @override
@@ -29957,6 +29933,9 @@ Core_Core.prototype.initSimpleTable = function (columns) {
29957
29933
  colCount = columns.length;
29958
29934
  this.setColumnCount(colCount);
29959
29935
  this.setDataColumnMap(columns);
29936
+ for(let c = 0; c < colCount; ++c) {
29937
+ this.setColumnField(c, columns[c]);
29938
+ }
29960
29939
  }
29961
29940
 
29962
29941
  let titleSect = this.addSection("title");
@@ -31898,6 +31877,12 @@ Core_Core._proto = Core_Core.prototype;
31898
31877
  * @property {Array.<string>} sortedFields An array of sortedField
31899
31878
  */
31900
31879
 
31880
+ /** @private
31881
+ * @type {string}
31882
+ *@constant
31883
+ */
31884
+ const ROW_DEF = "ROW_DEF";
31885
+
31901
31886
  /** @constructor
31902
31887
  * @extends {EventDispatcher}
31903
31888
  * @param {SortableTitlePlugin.Options=} options
@@ -31913,6 +31898,7 @@ let SortableTitlePlugin = function (options) { // TODO: Extract SortableTitlePlu
31913
31898
  _t._onColumnRemoved = _t._onColumnRemoved.bind(_t);
31914
31899
  _t._onItemSortingClicked = _t._onItemSortingClicked.bind(_t);
31915
31900
  _t.refresh = _t.refresh.bind(_t);
31901
+ _t._rowDefSorter = _t._rowDefSorter.bind(_t);
31916
31902
 
31917
31903
  _t._hosts = [];
31918
31904
  _t._sortLogic = {};
@@ -32074,6 +32060,11 @@ SortableTitlePlugin.prototype._frozenIndicator = false;
32074
32060
  * @type {boolean}
32075
32061
  */
32076
32062
  SortableTitlePlugin.prototype._rowDefMode = false;
32063
+ /**
32064
+ * @private
32065
+ * @type {Function}
32066
+ */
32067
+ SortableTitlePlugin.prototype._userComparer = null;
32077
32068
 
32078
32069
  /** @private
32079
32070
  * @type {!Object.<string, string>}
@@ -33250,6 +33241,21 @@ SortableTitlePlugin.prototype.setSortingSequence = function (sequence, colRef) {
33250
33241
  SortableTitlePlugin.prototype.clearAllColumnSortingSequences = function () {
33251
33242
  this._sortingSequenceMap = null;
33252
33243
  };
33244
+ /** @private
33245
+ * @param {Object} rowA
33246
+ * @param {Object} rowB
33247
+ * @param {number} sortOrder
33248
+ * @param {*} context
33249
+ * @returns {number}
33250
+ */
33251
+ SortableTitlePlugin.prototype._rowDefSorter = function (rowA, rowB, sortOrder, context) {
33252
+ return this._userComparer(
33253
+ rowA[ROW_DEF].getRowData(),
33254
+ rowB[ROW_DEF].getRowData(),
33255
+ sortOrder,
33256
+ context
33257
+ );
33258
+ };
33253
33259
  /** @public
33254
33260
  * @description Sorting all separators according to compare function. If compare function is not specified, separators will will be sort by current sorting states.
33255
33261
  * @param {Function} comparer Compare function
@@ -33258,16 +33264,21 @@ SortableTitlePlugin.prototype.sortSeparators = function (comparer) {
33258
33264
  let host = this._hosts[0];
33259
33265
  let dv = host.getDataSource();
33260
33266
  if(comparer){
33261
- dv.sortSeparators(comparer);
33267
+ if(this._rowDefMode) {
33268
+ this._userComparer = comparer;
33269
+ dv.sortSeparators(this._rowDefSorter);
33270
+ this._userComparer = null;
33271
+ } else {
33272
+ dv.sortSeparators(comparer);
33273
+ }
33262
33274
  } else {
33263
33275
  let sortLogics = dv.getSortingLogics();
33264
33276
  let sortOrders = [];
33265
33277
  let sortFields = [];
33266
33278
  let sortStateCount = this._sortStates.length;
33267
- let rowDefField = SortableTitlePlugin._toRowDefField();
33268
33279
  for(let i = 0; i < sortStateCount; i++){
33269
33280
  let sortState = this._sortStates[i];
33270
- let field = this._rowDefMode ? rowDefField : sortState["field"];
33281
+ let field = this._rowDefMode ? ROW_DEF : sortState["field"];
33271
33282
  sortOrders.push(sortState["sortOrder"]);
33272
33283
  sortFields.push(field);
33273
33284
  }
@@ -33517,11 +33528,10 @@ SortableTitlePlugin.prototype._onColumnRemoved = function (e) {
33517
33528
  };
33518
33529
 
33519
33530
  /** @private
33520
- * @param {Object=} sortState
33521
33531
  * @return {string}
33522
33532
  */
33523
- SortableTitlePlugin._toRowDefField = function(sortState) {
33524
- return "ROW_DEF";
33533
+ SortableTitlePlugin._toRowDefField = function() {
33534
+ return ROW_DEF;
33525
33535
  };
33526
33536
  /** @private
33527
33537
  * @param {Object=} opt_action Action that raised the sort. This is optional