@refinitiv-ui/efx-grid 6.0.19 → 6.0.21
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.
- package/lib/column-selection-dialog/lib/column-selection-dialog.d.ts +2 -1
- package/lib/column-selection-dialog/lib/column-selection-dialog.js +89 -8
- package/lib/filter-dialog/lib/checkbox-list.js +148 -81
- package/lib/filter-dialog/lib/filter-dialog.js +23 -10
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +124 -5
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.d.ts +6 -0
- package/lib/rt-grid/es6/Grid.js +124 -5
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +4 -4
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +162 -103
- package/lib/tr-grid-column-resizing/es6/ColumnResizing.js +11 -37
- package/lib/tr-grid-row-dragging/es6/RowDragging.d.ts +15 -14
- package/lib/tr-grid-row-dragging/es6/RowDragging.js +44 -6
- package/lib/tr-grid-row-selection/es6/RowSelection.d.ts +15 -15
- package/lib/tr-grid-row-selection/es6/RowSelection.js +9 -1
- package/lib/types/es6/ColumnGrouping.d.ts +4 -4
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +6 -0
- package/lib/types/es6/RowDragging.d.ts +15 -14
- package/lib/types/es6/RowGrouping.d.ts +5 -0
- package/lib/types/es6/RowSelection.d.ts +15 -15
- package/lib/versions.json +6 -6
- package/package.json +4 -1
@@ -257,6 +257,12 @@ declare class Grid extends EventDispatcher {
|
|
257
257
|
|
258
258
|
public freezeColumn(colIndex?: number|null, pinnedRightColumns?: number|null): void;
|
259
259
|
|
260
|
+
public pinColumn(colRef: Grid.ColumnReference|(Grid.ColumnReference)[]|null): boolean;
|
261
|
+
|
262
|
+
public unpinColumn(colRef: Grid.ColumnReference|(Grid.ColumnReference)[]|null, dest?: Grid.ColumnReference|null): boolean;
|
263
|
+
|
264
|
+
public unpinAllColumns(): boolean;
|
265
|
+
|
260
266
|
public updateColumnTitle(): void;
|
261
267
|
|
262
268
|
public isSorting(): boolean;
|
package/lib/rt-grid/es6/Grid.js
CHANGED
@@ -2965,17 +2965,136 @@ Grid.prototype.getAllFields = function() {
|
|
2965
2965
|
return this._connector.getAllFields();
|
2966
2966
|
};
|
2967
2967
|
/** Freeze the column at the left side of the table starting from index 0 to the specified colIndex
|
2968
|
-
|
2969
|
-
|
2970
|
-
|
2971
|
-
|
2972
|
-
|
2968
|
+
* If no index is specified (null or undefined index), unfreeze all columns.
|
2969
|
+
* @public
|
2970
|
+
* @param {number=} colIndex Negative index is equivalent to null value
|
2971
|
+
* @param {number=} pinnedRightColumns Number of columns to be pinned/snapped on the right side
|
2972
|
+
*/
|
2973
2973
|
Grid.prototype.freezeColumn = function(colIndex, pinnedRightColumns) {
|
2974
2974
|
if(colIndex == null) {
|
2975
2975
|
colIndex = -1;
|
2976
2976
|
}
|
2977
2977
|
this._grid.freezeColumn(colIndex, pinnedRightColumns);
|
2978
2978
|
};
|
2979
|
+
/** Pin column to the left side by moving the specified column to the rightmost of the frozen columns. <br>
|
2980
|
+
* The method will do nothing if the specified column is already pinned to the left side
|
2981
|
+
* @public
|
2982
|
+
* @param {Grid~ColumnReference|Array.<Grid~ColumnReference>} colRef
|
2983
|
+
* @return {boolean}
|
2984
|
+
*/
|
2985
|
+
Grid.prototype.pinColumn = function(colRef) {
|
2986
|
+
if(Array.isArray(colRef)) {
|
2987
|
+
var ary = colRef;
|
2988
|
+
var len = ary.length;
|
2989
|
+
|
2990
|
+
var dirty = 0;
|
2991
|
+
for(var i = 0; i < len; ++i) {
|
2992
|
+
dirty |= this._pinColumn(ary[i]);
|
2993
|
+
}
|
2994
|
+
return dirty ? true : false;
|
2995
|
+
}
|
2996
|
+
return this._pinColumn(colRef);
|
2997
|
+
};
|
2998
|
+
/** @private
|
2999
|
+
* @param {Grid~ColumnReference} colRef
|
3000
|
+
* @return {boolean}
|
3001
|
+
*/
|
3002
|
+
Grid.prototype._pinColumn = function(colRef) {
|
3003
|
+
var colIndex = this.getColumnIndex(colRef);
|
3004
|
+
if(colIndex < 0) {
|
3005
|
+
return false;
|
3006
|
+
}
|
3007
|
+
var pinnedCount = this._grid.getFrozenColumnCount();
|
3008
|
+
if(colIndex < pinnedCount) {
|
3009
|
+
return false; // The column is already pinned area
|
3010
|
+
}
|
3011
|
+
if(!pinnedCount) {
|
3012
|
+
var stationaryIdx = this._grid.getStationaryColumnIndex();
|
3013
|
+
if(stationaryIdx >= 0) {
|
3014
|
+
pinnedCount = stationaryIdx;
|
3015
|
+
if(colIndex > stationaryIdx) {
|
3016
|
+
pinnedCount++;
|
3017
|
+
}
|
3018
|
+
}
|
3019
|
+
}
|
3020
|
+
|
3021
|
+
this.moveColumnById(colIndex, pinnedCount);
|
3022
|
+
this._grid.freezeColumn(pinnedCount);
|
3023
|
+
return true;
|
3024
|
+
};
|
3025
|
+
/** Unpin column from the left side by moving the specified column to the end of the frozen columns. <br>
|
3026
|
+
* The method will do nothing if the specified column is not pinned on the left side.
|
3027
|
+
* @public
|
3028
|
+
* @param {Grid~ColumnReference|Array.<Grid~ColumnReference>} colRef
|
3029
|
+
* @param {Grid~ColumnReference=} dest The unpinned column will be placed before the destination position after the operation
|
3030
|
+
* @return {boolean}
|
3031
|
+
*/
|
3032
|
+
Grid.prototype.unpinColumn = function(colRef, dest) {
|
3033
|
+
if(Array.isArray(colRef)) {
|
3034
|
+
var ary = colRef;
|
3035
|
+
var len = ary.length;
|
3036
|
+
|
3037
|
+
var dirty = 0;
|
3038
|
+
for(var i = 0; i < len; ++i) {
|
3039
|
+
dirty |= this._unpinColumn(ary[i], dest);
|
3040
|
+
}
|
3041
|
+
return dirty ? true : false;
|
3042
|
+
}
|
3043
|
+
return this._unpinColumn(colRef, dest);
|
3044
|
+
};
|
3045
|
+
/** @private
|
3046
|
+
* @param {Grid~ColumnReference} colRef
|
3047
|
+
* @param {Grid~ColumnReference=} dest The unpinned column will be placed before the destination position after the operation
|
3048
|
+
* @return {boolean}
|
3049
|
+
*/
|
3050
|
+
Grid.prototype._unpinColumn = function(colRef, dest) {
|
3051
|
+
var colIndex = this.getColumnIndex(colRef);
|
3052
|
+
if(colIndex < 0) {
|
3053
|
+
return false;
|
3054
|
+
}
|
3055
|
+
var pinnedCount = this._grid.getFrozenColumnCount();
|
3056
|
+
if(!pinnedCount) {
|
3057
|
+
return false;
|
3058
|
+
}
|
3059
|
+
if(colIndex >= pinnedCount) {
|
3060
|
+
return false; // The column is outside of frozen area
|
3061
|
+
}
|
3062
|
+
var srcId = null;
|
3063
|
+
var destId = null;
|
3064
|
+
if(dest != null) {
|
3065
|
+
var destIdx = this.getColumnIndex(dest);
|
3066
|
+
destId = this.getColumnId(destIdx);
|
3067
|
+
srcId = this.getColumnId(colIndex);
|
3068
|
+
}
|
3069
|
+
|
3070
|
+
var stationaryIdx = this._grid.getStationaryColumnIndex();
|
3071
|
+
|
3072
|
+
if(colIndex > stationaryIdx) {
|
3073
|
+
this.moveColumnById(colIndex, pinnedCount);
|
3074
|
+
}
|
3075
|
+
|
3076
|
+
this._grid.freezeColumn(pinnedCount - 2); // Column index is used for freezing
|
3077
|
+
|
3078
|
+
if(colIndex > stationaryIdx) {
|
3079
|
+
if(destId != null) {
|
3080
|
+
this.moveColumnById(srcId, destId);
|
3081
|
+
}
|
3082
|
+
}
|
3083
|
+
|
3084
|
+
return true;
|
3085
|
+
};
|
3086
|
+
/** A shorthand to unpin all columns from the left hand side
|
3087
|
+
* @public
|
3088
|
+
* @return {boolean}
|
3089
|
+
*/
|
3090
|
+
Grid.prototype.unpinAllColumns = function() {
|
3091
|
+
var pinnedCount = this._grid.getFrozenColumnCount();
|
3092
|
+
if(!pinnedCount) {
|
3093
|
+
return false;
|
3094
|
+
}
|
3095
|
+
this._grid.freezeColumn(-1); // Column index is used for freezing
|
3096
|
+
return true;
|
3097
|
+
};
|
2979
3098
|
|
2980
3099
|
/** @private
|
2981
3100
|
* @param {Object} e
|
@@ -38,19 +38,19 @@ declare class ColumnGroupingPlugin extends GridPlugin {
|
|
38
38
|
|
39
39
|
public addColumnToGroup(column: any, groupId: string, colIndex: number): void;
|
40
40
|
|
41
|
-
public addGroup(groupDef: ColumnGroupingPlugin.GroupDefinition|null):
|
41
|
+
public addGroup(groupDef: ColumnGroupingPlugin.GroupDefinition|null): string;
|
42
42
|
|
43
43
|
public addColumnGrouping(groupDef: ColumnGroupingPlugin.GroupDefinition|null): void;
|
44
44
|
|
45
|
-
public removeGroup(groupId: string):
|
45
|
+
public removeGroup(groupId: string): ColumnGroupingPlugin.GroupDefinition|null;
|
46
46
|
|
47
|
-
public
|
47
|
+
public getGroupDefinition(groupId: string): ColumnGroupingPlugin.GroupDefinition|null;
|
48
48
|
|
49
49
|
public getGroupDefinitions(): ColumnGroupingPlugin.GroupDefinitions;
|
50
50
|
|
51
51
|
public setGroupDefinition(groupId: string, newDef: ColumnGroupingPlugin.GroupDefinition|null): void;
|
52
52
|
|
53
|
-
public
|
53
|
+
public setGroupDefinitions(groupDefs: ColumnGroupingPlugin.GroupDefinitions|null): void;
|
54
54
|
|
55
55
|
public setGroupChildren(groupId: string, newChildList: (string)[]|null): void;
|
56
56
|
|
@@ -113,6 +113,34 @@ ColumnGroupingPlugin._getTooltip = function (groupingOptions) {
|
|
113
113
|
}
|
114
114
|
return title;
|
115
115
|
};
|
116
|
+
/** @private
|
117
|
+
* @function
|
118
|
+
* @param {Object} groupDef
|
119
|
+
* @return {boolean}
|
120
|
+
*/
|
121
|
+
ColumnGroupingPlugin._isValidGroup = function (groupDef) {
|
122
|
+
if (groupDef) {
|
123
|
+
if (groupDef.id) {
|
124
|
+
return true;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
return false;
|
128
|
+
};
|
129
|
+
/** @private
|
130
|
+
* @function
|
131
|
+
* @param {Object} obj
|
132
|
+
* @return {Object}
|
133
|
+
*/
|
134
|
+
ColumnGroupingPlugin._cloneObject = function (obj) {
|
135
|
+
var newObj = cloneObject(obj);
|
136
|
+
if (Array.isArray(newObj.children)) {
|
137
|
+
newObj.children = newObj.children;
|
138
|
+
} else {
|
139
|
+
newObj.children = [];
|
140
|
+
}
|
141
|
+
return newObj;
|
142
|
+
};
|
143
|
+
|
116
144
|
/** @public
|
117
145
|
* @return {string}
|
118
146
|
*/
|
@@ -219,8 +247,8 @@ ColumnGroupingPlugin.prototype.config = function (options) {
|
|
219
247
|
}
|
220
248
|
var extOptions = options["columnGrouping"];
|
221
249
|
if (Array.isArray(extOptions)) {
|
222
|
-
var groupDefs = extOptions.
|
223
|
-
this._groupDefs = groupDefs.
|
250
|
+
var groupDefs = extOptions.filter(ColumnGroupingPlugin._isValidGroup);
|
251
|
+
this._groupDefs = groupDefs.map(ColumnGroupingPlugin._cloneObject);
|
224
252
|
}
|
225
253
|
var columns = options["columns"];
|
226
254
|
if (!columns) {
|
@@ -243,8 +271,10 @@ ColumnGroupingPlugin.prototype.getConfigObject = function (gridOptions) {
|
|
243
271
|
var obj = gridOptions || {};
|
244
272
|
|
245
273
|
// TODO: Handle legacyRender method that has been migrated
|
246
|
-
var
|
247
|
-
|
274
|
+
var groupDefs = this.getGroupDefinitions();
|
275
|
+
if (groupDefs.length) {
|
276
|
+
obj.columnGrouping = groupDefs;
|
277
|
+
}
|
248
278
|
return obj;
|
249
279
|
};
|
250
280
|
|
@@ -256,14 +286,6 @@ ColumnGroupingPlugin.prototype._setColumnGrouping = function (colIndex, data) {
|
|
256
286
|
var colData = this._newColumnData(colIndex);
|
257
287
|
colData["columnGrouping"] = data;
|
258
288
|
};
|
259
|
-
/** @private
|
260
|
-
* @param {number} colIndex
|
261
|
-
* @return {Object}
|
262
|
-
*/
|
263
|
-
ColumnGroupingPlugin.prototype._getColumnGrouping = function (colIndex) {
|
264
|
-
return this._getColumnOption(colIndex, "columnGrouping");
|
265
|
-
};
|
266
|
-
|
267
289
|
/** Legacy group structure from composite grid will be converted to the new structure
|
268
290
|
* @private
|
269
291
|
* @param {Object.<string, Array>} objMap
|
@@ -406,11 +428,12 @@ ColumnGroupingPlugin.prototype._evaluateGroupStructure = function () {
|
|
406
428
|
// Create child to parent map
|
407
429
|
var gid, children, member;
|
408
430
|
for (gid in groupMap) {
|
409
|
-
|
410
|
-
children
|
411
|
-
|
412
|
-
|
413
|
-
|
431
|
+
children = this._getAvaliableChildren(gid);
|
432
|
+
if (children.length > 1) {
|
433
|
+
for (i = 0; i < children.length; i++) {
|
434
|
+
member = children[i];
|
435
|
+
childToParent[member] = gid;
|
436
|
+
}
|
414
437
|
}
|
415
438
|
}
|
416
439
|
|
@@ -424,7 +447,7 @@ ColumnGroupingPlugin.prototype._evaluateGroupStructure = function () {
|
|
424
447
|
}
|
425
448
|
}
|
426
449
|
|
427
|
-
// Filter
|
450
|
+
// Filter out groups that are invisible
|
428
451
|
var rootGroup = [];
|
429
452
|
for (gid in visibleGroupMap) {
|
430
453
|
groupDef = visibleGroupMap[gid];
|
@@ -820,19 +843,7 @@ ColumnGroupingPlugin.prototype._onColumnRemoved = function (e) {
|
|
820
843
|
var colId = colData.columnGrouping.id;
|
821
844
|
var groupId = this._childToParent[colId];
|
822
845
|
if (groupId) {
|
823
|
-
|
824
|
-
if (groupDef) {
|
825
|
-
var children = groupDef.children;
|
826
|
-
var index = children.indexOf(colId);
|
827
|
-
if (index > -1) {
|
828
|
-
if (children.length < 3) {
|
829
|
-
this._groupDefs.splice(this._groupDefs.indexOf(groupDef), 1);
|
830
|
-
} else {
|
831
|
-
children.splice(index, 1);
|
832
|
-
}
|
833
|
-
this._requestApplyGrouping();
|
834
|
-
}
|
835
|
-
}
|
846
|
+
this._requestApplyGrouping();
|
836
847
|
}
|
837
848
|
}
|
838
849
|
};
|
@@ -940,22 +951,51 @@ ColumnGroupingPlugin.prototype.addColumnToGroup = function (column, groupId, col
|
|
940
951
|
}
|
941
952
|
};
|
942
953
|
|
943
|
-
/**
|
954
|
+
/** Remove each child from another group
|
955
|
+
* @private
|
956
|
+
* @param {Array.<string>} children
|
957
|
+
*/
|
958
|
+
ColumnGroupingPlugin.prototype._ungroupChildren = function (children) {
|
959
|
+
if (Array.isArray(children) && children.length) {
|
960
|
+
var childToParent = this._childToParent;
|
961
|
+
var groupMap = this._groupMap;
|
962
|
+
var len = children.length;
|
963
|
+
var childId, parentId, groupDef, at;
|
964
|
+
for (var i = 0; i < len; i++) {
|
965
|
+
childId = children[i];
|
966
|
+
parentId = childToParent[childId];
|
967
|
+
if (parentId) {
|
968
|
+
groupDef = groupMap[parentId];
|
969
|
+
if (groupDef) {
|
970
|
+
at = groupDef.children.indexOf(childId);
|
971
|
+
if (at > -1) {
|
972
|
+
groupDef.children.splice(at, 1);
|
973
|
+
}
|
974
|
+
}
|
975
|
+
}
|
976
|
+
}
|
977
|
+
}
|
978
|
+
};
|
979
|
+
|
980
|
+
/** Add new group definition to existing group structure. Existing group with the same id will be replaced.
|
944
981
|
* @public
|
945
982
|
* @param {ColumnGroupingPlugin~GroupDefinition} groupDef Group definition object
|
946
|
-
* @return {
|
983
|
+
* @return {string} Return group ID
|
947
984
|
*/
|
948
985
|
ColumnGroupingPlugin.prototype.addGroup = function (groupDef) {
|
949
|
-
if (groupDef
|
950
|
-
var curDef = this.
|
986
|
+
if (ColumnGroupingPlugin._isValidGroup(groupDef)) {
|
987
|
+
var curDef = this._groupMap[groupDef.id];
|
951
988
|
if (!curDef) {
|
952
989
|
var newGroupDef = ColumnGroupingPlugin._cloneObject(groupDef);
|
990
|
+
this._ungroupChildren(newGroupDef.children);
|
953
991
|
this._groupDefs.push(newGroupDef);
|
954
992
|
this._applyGrouping();
|
955
|
-
|
993
|
+
} else {
|
994
|
+
this.setGroupDefinition(groupDef.id, groupDef);
|
956
995
|
}
|
996
|
+
return groupDef.id;
|
957
997
|
}
|
958
|
-
return
|
998
|
+
return "";
|
959
999
|
};
|
960
1000
|
/** Deprecated. Use addGroup() method instead
|
961
1001
|
* @deprecated
|
@@ -967,10 +1007,10 @@ ColumnGroupingPlugin.prototype.addGroup = function (groupDef) {
|
|
967
1007
|
ColumnGroupingPlugin.prototype.addColumnGrouping = ColumnGroupingPlugin.prototype.addGroup;
|
968
1008
|
/** @public
|
969
1009
|
* @param {string} groupId
|
970
|
-
* @return {
|
1010
|
+
* @return {ColumnGroupingPlugin~GroupDefinition} Return removed group definition object.
|
971
1011
|
*/
|
972
1012
|
ColumnGroupingPlugin.prototype.removeGroup = function (groupId) {
|
973
|
-
var curDef = this.
|
1013
|
+
var curDef = this._groupMap[groupId];
|
974
1014
|
if (curDef) {
|
975
1015
|
var at = this._groupDefs.indexOf(curDef);
|
976
1016
|
this._groupDefs.splice(at, 1);
|
@@ -979,61 +1019,39 @@ ColumnGroupingPlugin.prototype.removeGroup = function (groupId) {
|
|
979
1019
|
return curDef;
|
980
1020
|
};
|
981
1021
|
|
982
|
-
/**
|
983
|
-
* @
|
984
|
-
* @
|
985
|
-
*/
|
986
|
-
ColumnGroupingPlugin.prototype.setGroupDefinitions = function (groupDefs) {
|
987
|
-
if (Array.isArray(groupDefs)) {
|
988
|
-
groupDefs = groupDefs.map(ColumnGroupingPlugin._cloneObject);
|
989
|
-
groupDefs = groupDefs.filter(ColumnGroupingPlugin._isValidGroup);
|
990
|
-
if (!groupDefs.length) {
|
991
|
-
groupDefs = null;
|
992
|
-
}
|
993
|
-
} else {
|
994
|
-
groupDefs = null;
|
995
|
-
}
|
996
|
-
if (groupDefs) {
|
997
|
-
this._groupDefs = groupDefs;
|
998
|
-
this._applyGrouping();
|
999
|
-
} else if (this._groupDefs.length) {
|
1000
|
-
this._groupDefs = [];
|
1001
|
-
this._applyGrouping();
|
1002
|
-
}
|
1003
|
-
};
|
1004
|
-
/** @private
|
1005
|
-
* @function
|
1006
|
-
* @param {Object} groupDef
|
1007
|
-
* @return {boolean}
|
1022
|
+
/** @public
|
1023
|
+
* @param {string} groupId
|
1024
|
+
* @return {ColumnGroupingPlugin~GroupDefinition}
|
1008
1025
|
*/
|
1009
|
-
ColumnGroupingPlugin.
|
1010
|
-
if (
|
1011
|
-
|
1012
|
-
|
1026
|
+
ColumnGroupingPlugin.prototype.getGroupDefinition = function (groupId) {
|
1027
|
+
if (groupId) {
|
1028
|
+
// Check for group validility
|
1029
|
+
var groupDef = this._groupMap[groupId];
|
1030
|
+
if (!groupDef) {
|
1031
|
+
return null;
|
1013
1032
|
}
|
1033
|
+
groupDef = ColumnGroupingPlugin._cloneObject(groupDef);
|
1034
|
+
var children = this._getAvaliableChildren(groupId);
|
1035
|
+
groupDef.children = children;
|
1036
|
+
return groupDef;
|
1014
1037
|
}
|
1015
|
-
return
|
1016
|
-
};
|
1017
|
-
/** @private
|
1018
|
-
* @function
|
1019
|
-
* @param {Object} obj
|
1020
|
-
* @return {boolean}
|
1021
|
-
*/
|
1022
|
-
ColumnGroupingPlugin._cloneObject = function (obj) {
|
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;
|
1038
|
+
return null;
|
1030
1039
|
};
|
1031
1040
|
/** Get a shallow copy of all existing group definitions
|
1032
1041
|
* @public
|
1033
1042
|
* @return {!ColumnGroupingPlugin~GroupDefinitions}
|
1034
1043
|
*/
|
1035
1044
|
ColumnGroupingPlugin.prototype.getGroupDefinitions = function () {
|
1036
|
-
|
1045
|
+
var validGroupDefs = [];
|
1046
|
+
var len = this._groupDefs.length;
|
1047
|
+
var groupDef;
|
1048
|
+
for (var i = 0; i < len; i++) {
|
1049
|
+
groupDef = this.getGroupDefinition(this._groupDefs[i].id);
|
1050
|
+
if (groupDef && groupDef.children.length > 1) {
|
1051
|
+
validGroupDefs.push(groupDef);
|
1052
|
+
}
|
1053
|
+
}
|
1054
|
+
return validGroupDefs;
|
1037
1055
|
};
|
1038
1056
|
/** Replace and update existing group definition. Existing group id will not be modified
|
1039
1057
|
* @public
|
@@ -1041,24 +1059,40 @@ ColumnGroupingPlugin.prototype.getGroupDefinitions = function () {
|
|
1041
1059
|
* @param {ColumnGroupingPlugin~GroupDefinition} newDef
|
1042
1060
|
*/
|
1043
1061
|
ColumnGroupingPlugin.prototype.setGroupDefinition = function (groupId, newDef) {
|
1044
|
-
|
1062
|
+
if (!groupId) {
|
1063
|
+
return;
|
1064
|
+
}
|
1065
|
+
var curDef = this._groupMap[groupId];
|
1045
1066
|
if (curDef) {
|
1046
|
-
var at = this._groupDefs.indexOf(curDef);
|
1047
1067
|
newDef = ColumnGroupingPlugin._cloneObject(newDef);
|
1048
1068
|
newDef.id = groupId;
|
1069
|
+
this._ungroupChildren(newDef.children);
|
1070
|
+
var at = this._groupDefs.indexOf(curDef);
|
1049
1071
|
this._groupDefs[at] = newDef;
|
1050
1072
|
this._applyGrouping();
|
1051
1073
|
}
|
1052
1074
|
};
|
1053
|
-
/**
|
1054
|
-
* @
|
1055
|
-
* @
|
1075
|
+
/** Remove all existing group definitions and replace with the given definitions.
|
1076
|
+
* @public
|
1077
|
+
* @param {ColumnGroupingPlugin~GroupDefinitions} groupDefs Use null or empty array to remove all existing groups
|
1056
1078
|
*/
|
1057
|
-
ColumnGroupingPlugin.prototype.
|
1058
|
-
if (
|
1059
|
-
|
1079
|
+
ColumnGroupingPlugin.prototype.setGroupDefinitions = function (groupDefs) {
|
1080
|
+
if (Array.isArray(groupDefs)) {
|
1081
|
+
groupDefs = groupDefs.filter(ColumnGroupingPlugin._isValidGroup);
|
1082
|
+
groupDefs = groupDefs.map(ColumnGroupingPlugin._cloneObject);
|
1083
|
+
if (!groupDefs.length) {
|
1084
|
+
groupDefs = null;
|
1085
|
+
}
|
1086
|
+
} else {
|
1087
|
+
groupDefs = null;
|
1088
|
+
}
|
1089
|
+
if (groupDefs) {
|
1090
|
+
this._groupDefs = groupDefs;
|
1091
|
+
this._applyGrouping();
|
1092
|
+
} else {
|
1093
|
+
this._groupDefs = [];
|
1094
|
+
this._applyGrouping();
|
1060
1095
|
}
|
1061
|
-
return null;
|
1062
1096
|
};
|
1063
1097
|
/** Replace and update existing group definition.
|
1064
1098
|
* @public
|
@@ -1066,10 +1100,11 @@ ColumnGroupingPlugin.prototype.getGroupDefinition = function (groupId) {
|
|
1066
1100
|
* @param {Array.<string>} newChildList If null is given, all existing children in the group will be removed
|
1067
1101
|
*/
|
1068
1102
|
ColumnGroupingPlugin.prototype.setGroupChildren = function (groupId, newChildList) {
|
1069
|
-
var groupDef = this.
|
1103
|
+
var groupDef = this._groupMap[groupId];
|
1070
1104
|
if (groupDef) {
|
1071
1105
|
if (Array.isArray(newChildList)) {
|
1072
1106
|
groupDef.aaa = 0; // TODO: for testing, need to be removed
|
1107
|
+
this._ungroupChildren(newChildList);
|
1073
1108
|
groupDef.children = newChildList.slice();
|
1074
1109
|
this._applyGrouping();
|
1075
1110
|
} else if (!newChildList && groupDef.children.length) {
|
@@ -1078,14 +1113,36 @@ ColumnGroupingPlugin.prototype.setGroupChildren = function (groupId, newChildLis
|
|
1078
1113
|
}
|
1079
1114
|
}
|
1080
1115
|
};
|
1116
|
+
/** @private
|
1117
|
+
* @param {string} groupId
|
1118
|
+
* @return {!Array.<string>}
|
1119
|
+
*/
|
1120
|
+
ColumnGroupingPlugin.prototype._getAvaliableChildren = function (groupId) {
|
1121
|
+
var groupDef = this._groupMap[groupId];
|
1122
|
+
var validChildren = [];
|
1123
|
+
if (groupDef) {
|
1124
|
+
// Filter out columns that do not exist
|
1125
|
+
var groupMap = this._groupMap;
|
1126
|
+
var children = groupDef.children;
|
1127
|
+
var childId;
|
1128
|
+
for (var i = 0; i < children.length; i++) {
|
1129
|
+
childId = children[i];
|
1130
|
+
if (groupMap[childId] || this.getColumnIndex(childId) > -1) {
|
1131
|
+
validChildren.push(childId);
|
1132
|
+
}
|
1133
|
+
}
|
1134
|
+
}
|
1135
|
+
return validChildren;
|
1136
|
+
};
|
1137
|
+
|
1081
1138
|
/** @public
|
1082
1139
|
* @param {string} groupId
|
1083
1140
|
* @return {Array.<string>}
|
1084
1141
|
*/
|
1085
1142
|
ColumnGroupingPlugin.prototype.getGroupChildren = function (groupId) {
|
1086
|
-
var
|
1087
|
-
if (
|
1088
|
-
return
|
1143
|
+
var children = this._getAvaliableChildren(groupId);
|
1144
|
+
if (children.length > 1) {
|
1145
|
+
return children;
|
1089
1146
|
}
|
1090
1147
|
return null;
|
1091
1148
|
};
|
@@ -1164,14 +1221,17 @@ ColumnGroupingPlugin.prototype.getGroupLevel = function (groupId) {
|
|
1164
1221
|
/** @private
|
1165
1222
|
* @param {Object.<string, ColumnGroupingPlugin~GroupDefinition>} groupMap
|
1166
1223
|
* @param {ColumnGroupingPlugin~GroupDefinition} group Group definition
|
1167
|
-
* @param {Array
|
1224
|
+
* @param {Array.<string>=} members
|
1168
1225
|
* @return {Array.<string>}
|
1169
1226
|
*/
|
1170
1227
|
ColumnGroupingPlugin.prototype._getGroupMembers = function (groupMap, group, members) {
|
1171
1228
|
if (!members) {
|
1172
1229
|
members = [];
|
1173
1230
|
}
|
1174
|
-
var children = group.
|
1231
|
+
var children = this._getAvaliableChildren(group.id);
|
1232
|
+
if (children.length < 2) {
|
1233
|
+
return members;
|
1234
|
+
}
|
1175
1235
|
var g, id;
|
1176
1236
|
for (var i = 0; i < children.length; i++) {
|
1177
1237
|
id = children[i];
|
@@ -1311,7 +1371,7 @@ ColumnGroupingPlugin.prototype.moveColumnIntoGroup = function (colRef, to, group
|
|
1311
1371
|
if (fromIndex == -1) {
|
1312
1372
|
return;
|
1313
1373
|
}
|
1314
|
-
var groupDef = this.
|
1374
|
+
var groupDef = this._groupMap[groupId];
|
1315
1375
|
if (!groupDef) {
|
1316
1376
|
for (var j = this._hosts.length; --j >= 0;) {
|
1317
1377
|
var grid = this._hosts[j];
|
@@ -1397,8 +1457,7 @@ ColumnGroupingPlugin.prototype.setColumnParent = function (colRef, groupId) {
|
|
1397
1457
|
if (!api) {
|
1398
1458
|
return;
|
1399
1459
|
}
|
1400
|
-
var
|
1401
|
-
var colCount = grid.getColumnCount();
|
1460
|
+
var colCount = this.getColumnCount();
|
1402
1461
|
var toIndex = -1;
|
1403
1462
|
var childIndices = this.getChildColumnIndices(groupId);
|
1404
1463
|
|
@@ -260,7 +260,6 @@ ColumnResizingPlugin.prototype.initialize = function (host, options) {
|
|
260
260
|
this.config(options);
|
261
261
|
ColumnResizingPlugin._applyStyles(host);
|
262
262
|
this._updateResizerCount(host);
|
263
|
-
this._updateResizeHitBoxPosition(host);
|
264
263
|
};
|
265
264
|
/** @public
|
266
265
|
* @param {Object} host core grid object
|
@@ -432,7 +431,7 @@ ColumnResizingPlugin.prototype.disableResizing = function(colIndex, opt_disabled
|
|
432
431
|
colData["noResizing"] = opt_disabled !== false;
|
433
432
|
|
434
433
|
for(var i = this._hosts.length; --i >= 0;) {
|
435
|
-
this.
|
434
|
+
this._updateResizerCount(this._hosts[i]);
|
436
435
|
}
|
437
436
|
};
|
438
437
|
|
@@ -603,7 +602,6 @@ ColumnResizingPlugin.prototype._updateResizers = function () {
|
|
603
602
|
for(var i = this._hosts.length; --i >= 0;) {
|
604
603
|
var host = this._hosts[i];
|
605
604
|
this._updateResizerCount(host);
|
606
|
-
this._updateResizeHitBoxPosition(host, 0);
|
607
605
|
}
|
608
606
|
}
|
609
607
|
};
|
@@ -881,7 +879,15 @@ ColumnResizingPlugin.prototype._updateResizerCount = function (host) {
|
|
881
879
|
boxes = col._resizers = [];
|
882
880
|
}
|
883
881
|
for (var j = 0; j < rowCount; j++) {
|
882
|
+
var disabled = false;
|
884
883
|
var cell = titleSect.getCell(c, j); // TODO: This can be optimized
|
884
|
+
var cellColSpan = titleSect.getCellColSpan(c, j);
|
885
|
+
if(cellColSpan){
|
886
|
+
var lastSpanCol = c + cellColSpan - 1;
|
887
|
+
disabled = this._getColumnOption(lastSpanCol, "noResizing");
|
888
|
+
} else {
|
889
|
+
disabled = this._getColumnOption(c, "noResizing");
|
890
|
+
}
|
885
891
|
var box = cell._resizer;
|
886
892
|
if (!box) {
|
887
893
|
box = this._newResizer();
|
@@ -890,6 +896,8 @@ ColumnResizingPlugin.prototype._updateResizerCount = function (host) {
|
|
890
896
|
cellElem.insertBefore(box, cellElem.firstChild);
|
891
897
|
boxes.push(box);
|
892
898
|
}
|
899
|
+
box._disabled = disabled; // disabled is an internal flag
|
900
|
+
box.style.display = (disabled) ? "none" : "";
|
893
901
|
}
|
894
902
|
}
|
895
903
|
}
|
@@ -913,40 +921,6 @@ ColumnResizingPlugin.prototype._newResizer = function (classStr) {
|
|
913
921
|
return box;
|
914
922
|
};
|
915
923
|
/** @private
|
916
|
-
* @param {Object} host core grid object
|
917
|
-
* @param {number=} from
|
918
|
-
*/
|
919
|
-
ColumnResizingPlugin.prototype._updateResizeHitBoxPosition = function (host, from) { // Slow
|
920
|
-
if(this._hbMode || this._disabled) {
|
921
|
-
return;
|
922
|
-
}
|
923
|
-
|
924
|
-
var titleSect = host.getSection("title");
|
925
|
-
if(!titleSect) {
|
926
|
-
return;
|
927
|
-
}
|
928
|
-
|
929
|
-
if(!from) {
|
930
|
-
from = 0;
|
931
|
-
}
|
932
|
-
|
933
|
-
var titleSects = host.getAllSections("title");
|
934
|
-
var colCount = host.getColumnCount();
|
935
|
-
for (var i = 0; i < titleSects.length; i++) {
|
936
|
-
titleSect = titleSects[i];
|
937
|
-
for (var c = from; c < colCount; ++c) {
|
938
|
-
var col = titleSect.getColumn(c);
|
939
|
-
var disabled = this._getColumnOption(c, "noResizing");
|
940
|
-
var boxes = col._resizers;
|
941
|
-
for (var j = 0; j < boxes.length; j++) {
|
942
|
-
var box = boxes[j];
|
943
|
-
box._disabled = disabled; // disabled is an internal flag
|
944
|
-
box.style.display = (disabled) ? "none" : "";
|
945
|
-
}
|
946
|
-
}
|
947
|
-
}
|
948
|
-
};
|
949
|
-
/** @private
|
950
924
|
* @param {Event} e
|
951
925
|
* @return {Object} host, core grid object
|
952
926
|
*/
|