@refinitiv-ui/efx-grid 6.0.17 → 6.0.19
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/column-format-dialog/themes/elemental/dark/column-format-dialog.js +1 -1
- package/lib/column-format-dialog/themes/elemental/dark/es5/all-elements.js +1 -1
- package/lib/column-format-dialog/themes/elemental/light/column-format-dialog.js +1 -1
- package/lib/column-format-dialog/themes/elemental/light/es5/all-elements.js +1 -1
- package/lib/column-format-dialog/themes/halo/dark/column-format-dialog.js +1 -1
- package/lib/column-format-dialog/themes/halo/dark/es5/all-elements.js +1 -1
- package/lib/column-format-dialog/themes/halo/light/column-format-dialog.js +1 -1
- package/lib/column-format-dialog/themes/halo/light/es5/all-elements.js +1 -1
- package/lib/column-format-dialog/themes/luna/default/column-format-dialog.js +1 -1
- package/lib/column-format-dialog/themes/luna/default/es5/all-elements.js +1 -1
- package/lib/column-format-dialog/themes/solar/charcoal/column-format-dialog.js +1 -1
- package/lib/column-format-dialog/themes/solar/charcoal/es5/all-elements.js +1 -1
- package/lib/column-format-dialog/themes/solar/pearl/column-format-dialog.js +1 -1
- package/lib/column-format-dialog/themes/solar/pearl/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/elemental/dark/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/elemental/dark/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/elemental/light/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/elemental/light/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/halo/dark/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/halo/dark/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/halo/light/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/halo/light/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/solar/charcoal/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/solar/charcoal/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/solar/pearl/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/solar/pearl/es5/all-elements.js +1 -1
- package/lib/core/dist/core.js +40 -23
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/DataView.d.ts +4 -0
- package/lib/core/es6/data/DataView.js +19 -1
- package/lib/core/es6/data/SegmentCollection.js +20 -8
- package/lib/core/es6/grid/Core.js +1 -1
- package/lib/core/es6/grid/components/Cell.js +0 -13
- package/lib/filter-dialog/lib/filter-dialog.js +149 -131
- package/lib/filter-dialog/themes/elemental/dark/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/elemental/dark/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/elemental/dark/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/elemental/light/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/elemental/light/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/elemental/light/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/halo/dark/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/halo/dark/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/halo/dark/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/halo/light/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/halo/light/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/halo/light/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/solar/charcoal/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/solar/charcoal/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/solar/charcoal/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/solar/pearl/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/solar/pearl/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/solar/pearl/filter-dialog.js +1 -1
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +198 -86
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/ColumnDefinition.js +2 -1
- package/lib/rt-grid/es6/Grid.d.ts +12 -2
- package/lib/rt-grid/es6/Grid.js +152 -54
- package/lib/rt-grid/es6/RowDefinition.js +4 -0
- package/lib/tr-grid-checkbox/es6/Checkbox.js +63 -12
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +150 -161
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +5 -9
- package/lib/tr-grid-filter-input/es6/FilterInput.d.ts +1 -0
- package/lib/tr-grid-filter-input/es6/FilterInput.js +36 -8
- package/lib/tr-grid-pagination/es6/Pagination.d.ts +1 -0
- package/lib/tr-grid-pagination/es6/Pagination.js +35 -29
- package/lib/tr-grid-row-grouping/es6/RowGrouping.d.ts +5 -0
- package/lib/tr-grid-row-grouping/es6/RowGrouping.js +30 -0
- package/lib/tr-grid-util/es6/Popup.js +5 -1
- package/lib/types/es6/ColumnGrouping.d.ts +4 -4
- package/lib/types/es6/Core/data/DataView.d.ts +4 -0
- package/lib/types/es6/FilterInput.d.ts +1 -0
- package/lib/types/es6/Pagination.d.ts +1 -0
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +12 -2
- package/lib/versions.json +9 -9
- package/package.json +1 -1
@@ -56,16 +56,16 @@ ColumnGroupingPlugin.prototype._groupDefs;
|
|
56
56
|
* @private
|
57
57
|
*/
|
58
58
|
ColumnGroupingPlugin.prototype._groupMap;
|
59
|
-
/** @type {!Object.<string, ColumnGroupingPlugin~GroupDefinition>}
|
60
|
-
* @description A map of visible group id to group defintion
|
61
|
-
* @private
|
62
|
-
*/
|
63
|
-
ColumnGroupingPlugin.prototype._visibleGroupMap;
|
64
59
|
/** @type {!Object.<string, string>}
|
65
60
|
* @description A map of child id to parent id
|
66
61
|
* @private
|
67
62
|
*/
|
68
63
|
ColumnGroupingPlugin.prototype._childToParent;
|
64
|
+
/** @type {!Object.<string, ColumnGroupingPlugin~GroupDefinition>}
|
65
|
+
* @description A map of visible group id to group defintion
|
66
|
+
* @private
|
67
|
+
*/
|
68
|
+
ColumnGroupingPlugin.prototype._visibleGroupMap;
|
69
69
|
/** @type {number}
|
70
70
|
* @private
|
71
71
|
*/
|
@@ -87,6 +87,14 @@ ColumnGroupingPlugin.prototype._addingTimerId = 0;
|
|
87
87
|
*/
|
88
88
|
ColumnGroupingPlugin.prototype._addingEvents = null;
|
89
89
|
|
90
|
+
/** @private
|
91
|
+
* @param {number} a
|
92
|
+
* @param {number} b
|
93
|
+
* @return {number}
|
94
|
+
*/
|
95
|
+
ColumnGroupingPlugin._ascSortLogic = function (a, b) {
|
96
|
+
return a - b;
|
97
|
+
};
|
90
98
|
/** @private
|
91
99
|
* @param {ColumnGroupingPlugin~GroupDefinition} groupingOptions
|
92
100
|
* @return {string}
|
@@ -305,7 +313,7 @@ ColumnGroupingPlugin.prototype._migrateLegacyStructure = function (colModels) {
|
|
305
313
|
|
306
314
|
// Add new definitions and structure to the given legacy objects
|
307
315
|
for (i = 0; i < groupCount; ++i) {
|
308
|
-
groupDef =
|
316
|
+
groupDef = ColumnGroupingPlugin._cloneObject(legacyColumnGroups[i]);
|
309
317
|
if (groupDef && groupDef.id) {
|
310
318
|
// WARNING: Modify user's object
|
311
319
|
var childAry = groupMap[groupDef.id];
|
@@ -317,6 +325,7 @@ ColumnGroupingPlugin.prototype._migrateLegacyStructure = function (colModels) {
|
|
317
325
|
this._groupDefs.push(groupDef);
|
318
326
|
}
|
319
327
|
}
|
328
|
+
this._groupDefs = this._groupDefs.filter(ColumnGroupingPlugin._isValidGroup);
|
320
329
|
};
|
321
330
|
|
322
331
|
/** Consolidate and process configuration. Force rerendering on column adding, removing, moving, initializaing, and run-time API execution.
|
@@ -390,7 +399,7 @@ ColumnGroupingPlugin.prototype._evaluateGroupStructure = function () {
|
|
390
399
|
groupMap[groupDef.id] = groupDef;
|
391
400
|
|
392
401
|
// Clone group definitions for rendering
|
393
|
-
visibleGroupMap[groupDef.id] =
|
402
|
+
visibleGroupMap[groupDef.id] = ColumnGroupingPlugin._cloneObject(groupDef);
|
394
403
|
visibleGroupMap[groupDef.id].children = groupDef.children.slice();
|
395
404
|
}
|
396
405
|
|
@@ -553,7 +562,14 @@ ColumnGroupingPlugin.prototype._applyNearestGrouping = function (colIndex) {
|
|
553
562
|
var groupLeftIds = this.getGroupIds(colIndexLeft);
|
554
563
|
var groupRightIds = this.getGroupIds(colIndexRight);
|
555
564
|
if (groupLeftIds && groupRightIds) {
|
556
|
-
var
|
565
|
+
var colId = this.getColumnId(colIndex);
|
566
|
+
var groupId = this._childToParent[colId];
|
567
|
+
if (groupId) {
|
568
|
+
if (groupLeftIds.indexOf(groupId) > -1 || groupRightIds.indexOf(groupId) > -1) {
|
569
|
+
return;
|
570
|
+
}
|
571
|
+
}
|
572
|
+
var i, j, groupLeftId, groupRightId;
|
557
573
|
var found = false;
|
558
574
|
for (i = 0; i < groupLeftIds.length; i++) {
|
559
575
|
groupLeftId = groupLeftIds[i];
|
@@ -561,12 +577,15 @@ ColumnGroupingPlugin.prototype._applyNearestGrouping = function (colIndex) {
|
|
561
577
|
groupRightId = groupRightIds[j];
|
562
578
|
if (groupLeftId === groupRightId) {
|
563
579
|
// found same Id between group
|
564
|
-
|
565
|
-
|
580
|
+
|
581
|
+
// This method modifies the group definition and outdates the group structure.
|
582
|
+
// It is necessary to recalculate group structure manually.
|
583
|
+
this._addGroupChild(colId, groupRightId);
|
566
584
|
found = true;
|
567
585
|
}
|
568
586
|
}
|
569
587
|
if (found) {
|
588
|
+
this._evaluateGroupStructure();
|
570
589
|
break;
|
571
590
|
}
|
572
591
|
}
|
@@ -603,23 +622,29 @@ ColumnGroupingPlugin.prototype._spanGroupVertically = function (titleSection) {
|
|
603
622
|
*/
|
604
623
|
ColumnGroupingPlugin.prototype._spanGroupHorizontally = function (titleSection) {
|
605
624
|
var section = titleSection;
|
606
|
-
var
|
625
|
+
var visibleGroupMap = this._visibleGroupMap;
|
607
626
|
|
608
627
|
// Span column of column group
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
var end = spanIndexes[1];
|
619
|
-
section.setCellColSpan(start, node["onRow"], end - start + 1);
|
620
|
-
node["colIndex"] = start;
|
628
|
+
var groupDef, spanIndices, len, colIds, index, i;
|
629
|
+
for (var id in visibleGroupMap) {
|
630
|
+
spanIndices = [];
|
631
|
+
groupDef = visibleGroupMap[id];
|
632
|
+
colIds = this._getGroupMembers(visibleGroupMap, groupDef);
|
633
|
+
for (i = 0; i < colIds.length; i++) {
|
634
|
+
index = this._getColumnIndexById(colIds[i]);
|
635
|
+
if (index > -1) {
|
636
|
+
spanIndices.push(index);
|
621
637
|
}
|
622
638
|
}
|
639
|
+
spanIndices.sort(ColumnGroupingPlugin._ascSortLogic);
|
640
|
+
len = spanIndices.length;
|
641
|
+
if (len > 0) {
|
642
|
+
// This could be unnecessary
|
643
|
+
var start = spanIndices[0];
|
644
|
+
var end = spanIndices[len - 1];
|
645
|
+
section.setCellColSpan(start, groupDef["onRow"], end - start + 1);
|
646
|
+
groupDef["colIndex"] = start;
|
647
|
+
}
|
623
648
|
}
|
624
649
|
};
|
625
650
|
/** @private
|
@@ -636,6 +661,9 @@ ColumnGroupingPlugin.prototype._renderGroups = function () {
|
|
636
661
|
for (var id in groupMap) {
|
637
662
|
var node = groupMap[id];
|
638
663
|
var colIndex = node["colIndex"];
|
664
|
+
if (colIndex == null) {
|
665
|
+
continue;
|
666
|
+
}
|
639
667
|
var rowIndex = node["onRow"];
|
640
668
|
var cell = section.getCell(colIndex, rowIndex);
|
641
669
|
if (cell) {
|
@@ -717,9 +745,17 @@ ColumnGroupingPlugin.prototype._applyTimeSeries = function (e) {
|
|
717
745
|
var groupDef = this._groupMap[groupId];
|
718
746
|
if (groupDef) {
|
719
747
|
// add children time series field to parent
|
748
|
+
var dirty = false;
|
749
|
+
var child;
|
720
750
|
for (i = 0; i < children.length; i++) {
|
721
|
-
|
722
|
-
|
751
|
+
child = children[i];
|
752
|
+
|
753
|
+
// This method modifies the group definition and outdates the group structure.
|
754
|
+
// It is necessary to recalculate group structure manually.
|
755
|
+
dirty |= this._addGroupChild(child, groupId);
|
756
|
+
}
|
757
|
+
if (dirty) {
|
758
|
+
this._evaluateGroupStructure();
|
723
759
|
}
|
724
760
|
} else {
|
725
761
|
// create new group
|
@@ -757,24 +793,22 @@ ColumnGroupingPlugin.prototype._onColumnMoved = function (e) {
|
|
757
793
|
var toColIndex = e.toColIndex;
|
758
794
|
var colId = this.getColumnId(toColIndex);
|
759
795
|
var groupId = this._childToParent[colId];
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
var groupChild = this.getGroupChildren(groupId);
|
770
|
-
var removeIndex = groupChild.indexOf(colId);
|
796
|
+
if (groupId) {
|
797
|
+
var colIdLeft = this.getColumnId(toColIndex - 1);
|
798
|
+
var colIdRight = this.getColumnId(toColIndex + 1);
|
799
|
+
var groupIdLeft = this._childToParent[colIdLeft];
|
800
|
+
var groupIdRight = this._childToParent[colIdRight];
|
801
|
+
if (groupId != groupIdLeft && groupId != groupIdRight) {
|
802
|
+
// Remove column from previous group
|
803
|
+
var children = this.getGroupChildren(groupId);
|
804
|
+
var removeIndex = children.indexOf(colId);
|
771
805
|
if (removeIndex > -1) {
|
772
|
-
|
806
|
+
children.splice(removeIndex, 1);
|
773
807
|
}
|
774
|
-
this.setGroupChildren(groupId,
|
808
|
+
this.setGroupChildren(groupId, children);
|
775
809
|
}
|
776
|
-
this._applyNearestGrouping(toColIndex);
|
777
810
|
}
|
811
|
+
this._applyNearestGrouping(toColIndex);
|
778
812
|
this._requestApplyGrouping();
|
779
813
|
};
|
780
814
|
/** @private
|
@@ -806,7 +840,7 @@ ColumnGroupingPlugin.prototype._onColumnRemoved = function (e) {
|
|
806
840
|
* @param {Object} e
|
807
841
|
*/
|
808
842
|
ColumnGroupingPlugin.prototype._onBeforeColumnBoundUpdate = function (e) {
|
809
|
-
var selectedColumns = e.selectedColumns;
|
843
|
+
var selectedColumns = e.selectedColumns; // Hidden columns are included
|
810
844
|
var parentMap = this._childToParent;
|
811
845
|
|
812
846
|
// Find non-grouped column
|
@@ -855,7 +889,7 @@ ColumnGroupingPlugin.prototype._onBeforeColumnBoundUpdate = function (e) {
|
|
855
889
|
for (groupId in findingGroup) {
|
856
890
|
group = findingGroup[groupId];
|
857
891
|
allSelected = true;
|
858
|
-
members = this._getGroupMembers(group);
|
892
|
+
members = this._getGroupMembers(this._groupMap, group);
|
859
893
|
if (members.length <= colIds.length) {
|
860
894
|
for (n = 0; n < members.length; n++) {
|
861
895
|
if (colIds.indexOf(members[n]) < 0) {
|
@@ -892,7 +926,13 @@ ColumnGroupingPlugin.prototype._onBeforeColumnBoundUpdate = function (e) {
|
|
892
926
|
ColumnGroupingPlugin.prototype.addColumnToGroup = function (column, groupId, colIndex) {
|
893
927
|
if (!column || !groupId) return;
|
894
928
|
var columnIndex = colIndex || this.getColumnCount();
|
895
|
-
|
929
|
+
|
930
|
+
// This method modifies the group definition and outdates the group structure.
|
931
|
+
// It is necessary to recalculate group structure manually.
|
932
|
+
if (this._addGroupChild(column.id, groupId)) {
|
933
|
+
this._evaluateGroupStructure(); // To prevent event handler from using outdated group structure
|
934
|
+
}
|
935
|
+
|
896
936
|
if (this._realTimeGrid) {
|
897
937
|
this._realTimeGrid.insertColumn(column, columnIndex);
|
898
938
|
} else if (this._compositeGrid) {
|
@@ -909,7 +949,7 @@ ColumnGroupingPlugin.prototype.addGroup = function (groupDef) {
|
|
909
949
|
if (groupDef && groupDef.id) {
|
910
950
|
var curDef = this.getGroupDefinition(groupDef.id);
|
911
951
|
if (!curDef) {
|
912
|
-
var newGroupDef =
|
952
|
+
var newGroupDef = ColumnGroupingPlugin._cloneObject(groupDef);
|
913
953
|
this._groupDefs.push(newGroupDef);
|
914
954
|
this._applyGrouping();
|
915
955
|
return true;
|
@@ -969,10 +1009,6 @@ ColumnGroupingPlugin.prototype.setGroupDefinitions = function (groupDefs) {
|
|
969
1009
|
ColumnGroupingPlugin._isValidGroup = function (groupDef) {
|
970
1010
|
if (groupDef) {
|
971
1011
|
if (groupDef.id) {
|
972
|
-
if (!groupDef.children) {
|
973
|
-
groupDef.children = []; // WARNING: Modify user's object
|
974
|
-
}
|
975
|
-
|
976
1012
|
return true;
|
977
1013
|
}
|
978
1014
|
}
|
@@ -984,7 +1020,13 @@ ColumnGroupingPlugin._isValidGroup = function (groupDef) {
|
|
984
1020
|
* @return {boolean}
|
985
1021
|
*/
|
986
1022
|
ColumnGroupingPlugin._cloneObject = function (obj) {
|
987
|
-
|
1023
|
+
var newObj = cloneObject(obj);
|
1024
|
+
if (Array.isArray(newObj.children)) {
|
1025
|
+
newObj.children = newObj.children;
|
1026
|
+
} else {
|
1027
|
+
newObj.children = [];
|
1028
|
+
}
|
1029
|
+
return newObj;
|
988
1030
|
};
|
989
1031
|
/** Get a shallow copy of all existing group definitions
|
990
1032
|
* @public
|
@@ -1002,7 +1044,7 @@ ColumnGroupingPlugin.prototype.setGroupDefinition = function (groupId, newDef) {
|
|
1002
1044
|
var curDef = this.getGroupDefinition(groupId);
|
1003
1045
|
if (curDef) {
|
1004
1046
|
var at = this._groupDefs.indexOf(curDef);
|
1005
|
-
newDef =
|
1047
|
+
newDef = ColumnGroupingPlugin._cloneObject(newDef);
|
1006
1048
|
newDef.id = groupId;
|
1007
1049
|
this._groupDefs[at] = newDef;
|
1008
1050
|
this._applyGrouping();
|
@@ -1027,6 +1069,7 @@ ColumnGroupingPlugin.prototype.setGroupChildren = function (groupId, newChildLis
|
|
1027
1069
|
var groupDef = this.getGroupDefinition(groupId);
|
1028
1070
|
if (groupDef) {
|
1029
1071
|
if (Array.isArray(newChildList)) {
|
1072
|
+
groupDef.aaa = 0; // TODO: for testing, need to be removed
|
1030
1073
|
groupDef.children = newChildList.slice();
|
1031
1074
|
this._applyGrouping();
|
1032
1075
|
} else if (!newChildList && groupDef.children.length) {
|
@@ -1042,9 +1085,8 @@ ColumnGroupingPlugin.prototype.setGroupChildren = function (groupId, newChildLis
|
|
1042
1085
|
ColumnGroupingPlugin.prototype.getGroupChildren = function (groupId) {
|
1043
1086
|
var groupDef = this.getGroupDefinition(groupId);
|
1044
1087
|
if (groupDef) {
|
1045
|
-
return groupDef.children
|
1088
|
+
return groupDef.children;
|
1046
1089
|
}
|
1047
|
-
|
1048
1090
|
return null;
|
1049
1091
|
};
|
1050
1092
|
|
@@ -1056,7 +1098,7 @@ ColumnGroupingPlugin.prototype.getGroupChildren = function (groupId) {
|
|
1056
1098
|
ColumnGroupingPlugin.prototype.getChildColumnIndices = function (groupId) {
|
1057
1099
|
var group = this._groupMap[groupId];
|
1058
1100
|
if (group) {
|
1059
|
-
var colIds = this._getGroupMembers(group);
|
1101
|
+
var colIds = this._getGroupMembers(this._groupMap, group);
|
1060
1102
|
var colIndices = [];
|
1061
1103
|
var index;
|
1062
1104
|
for (var i = 0; i < colIds.length; i++) {
|
@@ -1065,7 +1107,7 @@ ColumnGroupingPlugin.prototype.getChildColumnIndices = function (groupId) {
|
|
1065
1107
|
colIndices.push(index);
|
1066
1108
|
}
|
1067
1109
|
}
|
1068
|
-
return colIndices.sort();
|
1110
|
+
return colIndices.sort(ColumnGroupingPlugin._ascSortLogic);
|
1069
1111
|
}
|
1070
1112
|
return null;
|
1071
1113
|
};
|
@@ -1120,22 +1162,26 @@ ColumnGroupingPlugin.prototype.getGroupLevel = function (groupId) {
|
|
1120
1162
|
};
|
1121
1163
|
|
1122
1164
|
/** @private
|
1165
|
+
* @param {Object.<string, ColumnGroupingPlugin~GroupDefinition>} groupMap
|
1123
1166
|
* @param {ColumnGroupingPlugin~GroupDefinition} group Group definition
|
1124
1167
|
* @param {Array=} members
|
1125
1168
|
* @return {Array.<string>}
|
1126
1169
|
*/
|
1127
|
-
ColumnGroupingPlugin.prototype._getGroupMembers = function (group, members) {
|
1170
|
+
ColumnGroupingPlugin.prototype._getGroupMembers = function (groupMap, group, members) {
|
1128
1171
|
if (!members) {
|
1129
1172
|
members = [];
|
1130
1173
|
}
|
1131
1174
|
var children = group.children;
|
1132
|
-
var groupMap = this._groupMap;
|
1133
1175
|
var g, id;
|
1134
1176
|
for (var i = 0; i < children.length; i++) {
|
1135
1177
|
id = children[i];
|
1178
|
+
if (id === group.id) {
|
1179
|
+
// prevent from infinite loop
|
1180
|
+
continue;
|
1181
|
+
}
|
1136
1182
|
g = groupMap[id];
|
1137
1183
|
if (g) {
|
1138
|
-
this._getGroupMembers(g, members);
|
1184
|
+
this._getGroupMembers(groupMap, g, members);
|
1139
1185
|
} else {
|
1140
1186
|
members.push(id);
|
1141
1187
|
}
|
@@ -1176,82 +1222,11 @@ ColumnGroupingPlugin.prototype._getColumnIndexById = function (id) {
|
|
1176
1222
|
}
|
1177
1223
|
return -1;
|
1178
1224
|
};
|
1179
|
-
/**
|
1180
|
-
* @
|
1181
|
-
* @param {Array} cluster
|
1182
|
-
*/
|
1183
|
-
ColumnGroupingPlugin.prototype._findColumnIndexArr = function (node, cluster) {
|
1184
|
-
if (node) {
|
1185
|
-
var childrens = node.children;
|
1186
|
-
if (childrens && childrens.length) {
|
1187
|
-
for (var i = 0; i < childrens.length; i++) {
|
1188
|
-
var child = childrens[i];
|
1189
|
-
if (!child.id) {
|
1190
|
-
if (!this._visibleGroupMap[child]) {
|
1191
|
-
var colIndex = this._getColumnIndexById(child);
|
1192
|
-
if (colIndex !== -1) {
|
1193
|
-
cluster.push(colIndex);
|
1194
|
-
}
|
1195
|
-
} else {
|
1196
|
-
this._findColumnIndexArr(this._visibleGroupMap[child], cluster);
|
1197
|
-
}
|
1198
|
-
} else {
|
1199
|
-
// skip children that has same id as parent
|
1200
|
-
if (child.id === node.id) {
|
1201
|
-
return;
|
1202
|
-
}
|
1203
|
-
this._findColumnIndexArr(this._visibleGroupMap[child.id], cluster);
|
1204
|
-
}
|
1205
|
-
}
|
1206
|
-
}
|
1207
|
-
}
|
1208
|
-
};
|
1209
|
-
/** @private
|
1210
|
-
* @param {Object} node
|
1211
|
-
* @return {Array} group of span index
|
1212
|
-
*/
|
1213
|
-
ColumnGroupingPlugin.prototype._findColumnSpans = function (node) {
|
1214
|
-
var cluster = [];
|
1215
|
-
this._findColumnIndexArr(node, cluster); // Recursively get column index
|
1216
|
-
|
1217
|
-
return ColumnGroupingPlugin._groupConsecutiveArr(cluster);
|
1218
|
-
};
|
1219
|
-
/** @private
|
1220
|
-
* @param {Array} arr
|
1221
|
-
* @return {Array} group of Consecutive number
|
1222
|
-
*/
|
1223
|
-
ColumnGroupingPlugin._groupConsecutiveArr = function (arr) {
|
1224
|
-
var result = [];
|
1225
|
-
if (!arr || !arr.length) {
|
1226
|
-
return result;
|
1227
|
-
}
|
1228
|
-
var array = arr.sort(function (a, b) {
|
1229
|
-
return a - b;
|
1230
|
-
});
|
1231
|
-
var start = array[0];
|
1232
|
-
var stop = start;
|
1233
|
-
// start at second member of array
|
1234
|
-
for (var i = 1; i <= array.length; i++) {
|
1235
|
-
var next = array[i];
|
1236
|
-
if (next === stop + 1) {
|
1237
|
-
// move to next member
|
1238
|
-
stop = next;
|
1239
|
-
} else {
|
1240
|
-
if (start === stop) {
|
1241
|
-
result.push([start, start]);
|
1242
|
-
} else {
|
1243
|
-
result.push([start, stop]);
|
1244
|
-
}
|
1245
|
-
// reset the start and stop pointers
|
1246
|
-
start = array[i];
|
1247
|
-
stop = start;
|
1248
|
-
}
|
1249
|
-
}
|
1250
|
-
return result;
|
1251
|
-
};
|
1252
|
-
/** @private
|
1225
|
+
/** This method modifies the group definition and outdates the group structure. It is necessary to recalculate group structure manually.
|
1226
|
+
* @private
|
1253
1227
|
* @param {string} childId
|
1254
1228
|
* @param {string} groupId
|
1229
|
+
* @return {boolean}
|
1255
1230
|
*/
|
1256
1231
|
ColumnGroupingPlugin.prototype._addGroupChild = function (childId, groupId) {
|
1257
1232
|
var groupDef = this._groupMap[groupId];
|
@@ -1259,8 +1234,10 @@ ColumnGroupingPlugin.prototype._addGroupChild = function (childId, groupId) {
|
|
1259
1234
|
var chdr = groupDef.children;
|
1260
1235
|
if (chdr && chdr.indexOf(childId) < 0) {
|
1261
1236
|
chdr.push(childId);
|
1237
|
+
return true;
|
1262
1238
|
}
|
1263
1239
|
}
|
1240
|
+
return false;
|
1264
1241
|
};
|
1265
1242
|
/** @private
|
1266
1243
|
* @param {string} childId
|
@@ -1325,17 +1302,12 @@ ColumnGroupingPlugin.prototype.getCellInfo = function (e) {
|
|
1325
1302
|
return cellInfo;
|
1326
1303
|
};
|
1327
1304
|
/** @public
|
1328
|
-
* @param {number|string} colRef
|
1305
|
+
* @param {number|string} colRef Column index or id that should be moved
|
1329
1306
|
* @param {number} to
|
1330
1307
|
* @param {string} groupId
|
1331
1308
|
*/
|
1332
1309
|
ColumnGroupingPlugin.prototype.moveColumnIntoGroup = function (colRef, to, groupId) {
|
1333
|
-
var fromIndex =
|
1334
|
-
if (typeof colRef == "string") {
|
1335
|
-
fromIndex = this._getColumnIndexById(colRef);
|
1336
|
-
} else {
|
1337
|
-
fromIndex = colRef;
|
1338
|
-
}
|
1310
|
+
var fromIndex = this.getColumnIndex(colRef);
|
1339
1311
|
if (fromIndex == -1) {
|
1340
1312
|
return;
|
1341
1313
|
}
|
@@ -1353,6 +1325,9 @@ ColumnGroupingPlugin.prototype.moveColumnIntoGroup = function (colRef, to, group
|
|
1353
1325
|
if (childIndices && childIndices.length) {
|
1354
1326
|
startIndex = childIndices[0];
|
1355
1327
|
endIndex = childIndices[childIndices.length - 1];
|
1328
|
+
} else {
|
1329
|
+
startIndex = 0;
|
1330
|
+
endIndex = this.getColumnCount();
|
1356
1331
|
}
|
1357
1332
|
if (to < startIndex) {
|
1358
1333
|
to = startIndex;
|
@@ -1368,49 +1343,53 @@ ColumnGroupingPlugin.prototype.moveColumnIntoGroup = function (colRef, to, group
|
|
1368
1343
|
}
|
1369
1344
|
}
|
1370
1345
|
|
1371
|
-
//
|
1346
|
+
// Calculate left and right bound of the group, which column can be moved to.
|
1347
|
+
// destination should be between the bound, and it should not be placed between columns in child group
|
1372
1348
|
for (var i = 0; i < groupDef.children.length; i++) {
|
1373
1349
|
var notAllowIndices = this.getChildColumnIndices(groupDef.children[i]);
|
1374
1350
|
if (notAllowIndices && notAllowIndices.length) {
|
1375
|
-
var
|
1376
|
-
var
|
1351
|
+
var leftLimit = notAllowIndices[0];
|
1352
|
+
var rightLimit = notAllowIndices[notAllowIndices.length - 1];
|
1377
1353
|
if (to > fromIndex) {
|
1378
|
-
|
1354
|
+
leftLimit -= 1;
|
1379
1355
|
}
|
1380
1356
|
if (to < fromIndex) {
|
1381
|
-
|
1357
|
+
rightLimit += 1;
|
1382
1358
|
}
|
1383
|
-
if (to >
|
1384
|
-
to =
|
1359
|
+
if (to > leftLimit && to < rightLimit) {
|
1360
|
+
to = rightLimit;
|
1385
1361
|
}
|
1386
1362
|
}
|
1387
1363
|
}
|
1364
|
+
|
1365
|
+
// Get column id before start moving
|
1366
|
+
var colId = this.getColumnId(fromIndex);
|
1388
1367
|
for (var gridIndex = this._hosts.length; --gridIndex >= 0;) {
|
1389
1368
|
var host = this._hosts[gridIndex];
|
1390
1369
|
host.moveColumn(fromIndex, to);
|
1391
1370
|
}
|
1371
|
+
if (colId) {
|
1372
|
+
// Remove from current group
|
1373
|
+
var previousGroup = this._childToParent[colId];
|
1374
|
+
if (previousGroup) {
|
1375
|
+
var previousGroupChild = this.getGroupChildren(previousGroup);
|
1376
|
+
var removeIndex = previousGroupChild.indexOf(colId);
|
1377
|
+
if (removeIndex !== -1) {
|
1378
|
+
previousGroupChild.splice(previousGroupChild.indexOf(colId), 1);
|
1379
|
+
}
|
1380
|
+
this.setGroupChildren(previousGroup, previousGroupChild);
|
1381
|
+
}
|
1392
1382
|
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
if (previousGroup) {
|
1397
|
-
var previousGroupChild = this.getGroupChildren(previousGroup);
|
1398
|
-
previousGroupChild.splice(previousGroupChild.indexOf(colId), 1);
|
1399
|
-
this.setGroupChildren(previousGroup, previousGroupChild);
|
1400
|
-
}
|
1401
|
-
|
1402
|
-
//apply new group
|
1403
|
-
var children = this.getGroupChildren(groupId);
|
1404
|
-
if (children.indexOf(colId) == -1) {
|
1405
|
-
if (colId) {
|
1383
|
+
// Add to new group
|
1384
|
+
var children = this.getGroupChildren(groupId);
|
1385
|
+
if (children.indexOf(colId) < 0) {
|
1406
1386
|
children.push(colId);
|
1387
|
+
this.setGroupChildren(groupId, children);
|
1407
1388
|
}
|
1408
1389
|
}
|
1409
|
-
this.setGroupChildren(groupId, children);
|
1410
|
-
this._requestApplyGrouping();
|
1411
1390
|
};
|
1412
1391
|
/** @public
|
1413
|
-
* @param {number|string} colRef
|
1392
|
+
* @param {number|string} colRef Column index or id that should be moved
|
1414
1393
|
* @param {string} groupId
|
1415
1394
|
*/
|
1416
1395
|
ColumnGroupingPlugin.prototype.setColumnParent = function (colRef, groupId) {
|
@@ -1420,7 +1399,17 @@ ColumnGroupingPlugin.prototype.setColumnParent = function (colRef, groupId) {
|
|
1420
1399
|
}
|
1421
1400
|
var grid = this._hosts[0];
|
1422
1401
|
var colCount = grid.getColumnCount();
|
1423
|
-
|
1402
|
+
var toIndex = -1;
|
1403
|
+
var childIndices = this.getChildColumnIndices(groupId);
|
1404
|
+
|
1405
|
+
// When group has at least one child, move column to last index within a group
|
1406
|
+
// Otherwise, column will not be moved
|
1407
|
+
if (childIndices && childIndices.length) {
|
1408
|
+
toIndex = colCount;
|
1409
|
+
} else {
|
1410
|
+
toIndex = this.getColumnIndex(colRef);
|
1411
|
+
}
|
1412
|
+
this.moveColumnIntoGroup(colRef, toIndex, groupId);
|
1424
1413
|
};
|
1425
1414
|
export default ColumnGroupingPlugin;
|
1426
1415
|
export { ColumnGroupingPlugin, ColumnGroupingPlugin as ColumnGrouping, ColumnGroupingPlugin as ColumnGroupingExtension };
|
@@ -311,15 +311,10 @@ ColumnStackPlugin.prototype.getConfigObject = function (gridOptions) {
|
|
311
311
|
if(columnOptions && columnOptions.length){
|
312
312
|
var memberIndices = this.getStackMemberIndices(stackOption.stackId);
|
313
313
|
for(var i = 0; i < memberIndices.length; i++){
|
314
|
-
var
|
314
|
+
var colIndex = memberIndices[i];
|
315
|
+
var colOption = columnOptions[colIndex];
|
315
316
|
if(colOption){
|
316
|
-
|
317
|
-
if(colOption["hidden"]) {
|
318
|
-
delete colOption["hidden"];
|
319
|
-
}
|
320
|
-
} else {
|
321
|
-
colOption.hidden = true;
|
322
|
-
}
|
317
|
+
colOption.hidden = colIndex !== activeColIndex;
|
323
318
|
}
|
324
319
|
}
|
325
320
|
}
|
@@ -1423,7 +1418,8 @@ ColumnStackPlugin.prototype._onStackButtonClicked = function(e) {
|
|
1423
1418
|
menuData[i] = {
|
1424
1419
|
value: i,
|
1425
1420
|
selected: i === activeIndex,
|
1426
|
-
label: this.getColumnName(colIndices[i])
|
1421
|
+
label: this.getColumnName(colIndices[i]),
|
1422
|
+
field: this._getField(colIndices[i])
|
1427
1423
|
};
|
1428
1424
|
}
|
1429
1425
|
pos["menuData"] = menuData;
|