@refinitiv-ui/efx-grid 6.0.16 → 6.0.17
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/grid/index.js +1 -1
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +4 -4
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +271 -141
- package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +7 -1
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +167 -146
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.d.ts +44 -43
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +202 -497
- package/lib/tr-grid-row-grouping/es6/RowGrouping.d.ts +40 -40
- package/lib/types/es6/ColumnStack.d.ts +7 -1
- package/lib/types/es6/Core/data/Segment.d.ts +3 -3
- package/lib/types/es6/Core/data/SegmentCollection.d.ts +1 -1
- package/lib/types/es6/InCellEditing.d.ts +44 -43
- package/lib/types/es6/RealtimeGrid/ColumnDefinition.d.ts +10 -0
- package/lib/types/es6/RealtimeGrid/FieldDefinition.d.ts +6 -0
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +2 -0
- package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +4 -0
- package/lib/types/es6/RealtimeGrid/SnapshotFiller.d.ts +1 -0
- package/lib/types/es6/RowColoring.d.ts +17 -15
- package/lib/types/es6/RowFiltering.d.ts +30 -29
- package/lib/types/es6/RowGrouping.d.ts +40 -40
- package/lib/versions.json +4 -4
- package/package.json +1 -1
package/lib/grid/index.js
CHANGED
@@ -24,12 +24,12 @@ declare class ColumnGroupingPlugin extends GridPlugin {
|
|
24
24
|
|
25
25
|
constructor(options?: ColumnGroupingPlugin.Options|null);
|
26
26
|
|
27
|
-
public beforeProcessOption(optionName: string, optionValue: any): any;
|
28
|
-
|
29
27
|
public getName(): string;
|
30
28
|
|
31
29
|
public initialize(host: any, options?: any): void;
|
32
30
|
|
31
|
+
public beforeProcessOption(optionName: string, optionValue: any): any;
|
32
|
+
|
33
33
|
public unload(host: any): void;
|
34
34
|
|
35
35
|
public config(options: any): void;
|
@@ -66,9 +66,9 @@ declare class ColumnGroupingPlugin extends GridPlugin {
|
|
66
66
|
|
67
67
|
public getCellInfo(e: Element|Event|MouseEvent|null): any;
|
68
68
|
|
69
|
-
public moveColumnIntoGroup(
|
69
|
+
public moveColumnIntoGroup(colRef: number|string|null, to: number, groupId: string): void;
|
70
70
|
|
71
|
-
public setColumnParent(
|
71
|
+
public setColumnParent(colRef: number|string|null, groupId: string): void;
|
72
72
|
|
73
73
|
}
|
74
74
|
|
@@ -31,6 +31,7 @@ var ColumnGroupingPlugin = function ColumnGroupingPlugin(options) {
|
|
31
31
|
t._onColumnChanged = t._onColumnChanged.bind(t);
|
32
32
|
t._onColumnAdded = t._onColumnAdded.bind(t);
|
33
33
|
t._onColumnMoved = t._onColumnMoved.bind(t);
|
34
|
+
t._onColumnRemoved = t._onColumnRemoved.bind(t);
|
34
35
|
t._requestApplyAddChildGroup = t._requestApplyAddChildGroup.bind(this);
|
35
36
|
t._onPostSectionRender = t._onPostSectionRender.bind(t);
|
36
37
|
t._onBeforeColumnBoundUpdate = t._onBeforeColumnBoundUpdate.bind(t);
|
@@ -55,6 +56,11 @@ ColumnGroupingPlugin.prototype._groupDefs;
|
|
55
56
|
* @private
|
56
57
|
*/
|
57
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;
|
58
64
|
/** @type {!Object.<string, string>}
|
59
65
|
* @description A map of child id to parent id
|
60
66
|
* @private
|
@@ -99,20 +105,6 @@ ColumnGroupingPlugin._getTooltip = function (groupingOptions) {
|
|
99
105
|
}
|
100
106
|
return title;
|
101
107
|
};
|
102
|
-
/** Prevent built-in config
|
103
|
-
* @public
|
104
|
-
* @param {string} optionName
|
105
|
-
* @param {Object} optionValue
|
106
|
-
* @return {*}
|
107
|
-
*/
|
108
|
-
ColumnGroupingPlugin.prototype.beforeProcessOption = function (optionName, optionValue) {
|
109
|
-
if (optionName === "columnGroups") {
|
110
|
-
this._legacyColumnGroups = optionValue;
|
111
|
-
return false; // eslint-disable-line
|
112
|
-
}
|
113
|
-
|
114
|
-
return; // eslint-disable-line
|
115
|
-
};
|
116
108
|
/** @public
|
117
109
|
* @return {string}
|
118
110
|
*/
|
@@ -142,7 +134,7 @@ ColumnGroupingPlugin.prototype.initialize = function (host, options) {
|
|
142
134
|
if (this._hosts.length === 1) {
|
143
135
|
host.listen("columnAdded", this._onColumnAdded);
|
144
136
|
host.listen("columnMoved", this._onColumnMoved);
|
145
|
-
host.listen("columnRemoved", this.
|
137
|
+
host.listen("columnRemoved", this._onColumnRemoved);
|
146
138
|
host.listen("columnVisibilityChanged", this._onColumnChanged);
|
147
139
|
host.listen("postSectionRender", this._onPostSectionRender);
|
148
140
|
host.listen("beforeColumnBoundUpdate", this._onBeforeColumnBoundUpdate);
|
@@ -162,6 +154,20 @@ ColumnGroupingPlugin.prototype.initialize = function (host, options) {
|
|
162
154
|
}
|
163
155
|
// TODO: wrong render group in hide/show column
|
164
156
|
};
|
157
|
+
/** Prevent built-in config
|
158
|
+
* @public
|
159
|
+
* @param {string} optionName
|
160
|
+
* @param {Object} optionValue
|
161
|
+
* @return {*}
|
162
|
+
*/
|
163
|
+
ColumnGroupingPlugin.prototype.beforeProcessOption = function (optionName, optionValue) {
|
164
|
+
if (optionName === "columnGroups") {
|
165
|
+
this._legacyColumnGroups = optionValue;
|
166
|
+
return false; // eslint-disable-line
|
167
|
+
}
|
168
|
+
|
169
|
+
return; // eslint-disable-line
|
170
|
+
};
|
165
171
|
/**
|
166
172
|
* @protected
|
167
173
|
* @ignore
|
@@ -180,7 +186,7 @@ ColumnGroupingPlugin.prototype.unload = function (host) {
|
|
180
186
|
this._hosts.splice(at, 1);
|
181
187
|
host.unlisten("columnAdded", this._onColumnChanged);
|
182
188
|
host.unlisten("columnMoved", this._onColumnMoved);
|
183
|
-
host.unlisten("columnRemoved", this.
|
189
|
+
host.unlisten("columnRemoved", this._onColumnRemoved);
|
184
190
|
host.unlisten("postSectionRender", this._onPostSectionRender);
|
185
191
|
host.unlisten("beforeColumnBoundUpdate", this._onBeforeColumnBoundUpdate);
|
186
192
|
if (!this._hosts.length) {
|
@@ -205,8 +211,20 @@ ColumnGroupingPlugin.prototype.config = function (options) {
|
|
205
211
|
}
|
206
212
|
var extOptions = options["columnGrouping"];
|
207
213
|
if (Array.isArray(extOptions)) {
|
208
|
-
|
214
|
+
var groupDefs = extOptions.map(ColumnGroupingPlugin._cloneObject);
|
215
|
+
this._groupDefs = groupDefs.filter(ColumnGroupingPlugin._isValidGroup);
|
216
|
+
}
|
217
|
+
var columns = options["columns"];
|
218
|
+
if (!columns) {
|
219
|
+
return;
|
209
220
|
}
|
221
|
+
var len = columns.length;
|
222
|
+
for (var i = 0; i < len; ++i) {
|
223
|
+
this._setColumnGrouping(i, {
|
224
|
+
id: columns[i].id
|
225
|
+
}); // used for columnRemoved event
|
226
|
+
}
|
227
|
+
|
210
228
|
this._migrateLegacyStructure(options["columns"]);
|
211
229
|
};
|
212
230
|
/** @public
|
@@ -218,13 +236,26 @@ ColumnGroupingPlugin.prototype.getConfigObject = function (gridOptions) {
|
|
218
236
|
|
219
237
|
// TODO: Handle legacyRender method that has been migrated
|
220
238
|
var columnGroupingDefs = this.getGroupDefinitions();
|
221
|
-
for (var i = 0; i < columnGroupingDefs.length; i++) {
|
222
|
-
columnGroupingDefs[i] = this._groupMap[columnGroupingDefs[i].id];
|
223
|
-
}
|
224
239
|
obj.columnGrouping = columnGroupingDefs;
|
225
240
|
return obj;
|
226
241
|
};
|
227
242
|
|
243
|
+
/** @private
|
244
|
+
* @param {number} colIndex
|
245
|
+
* @param {Object} data
|
246
|
+
*/
|
247
|
+
ColumnGroupingPlugin.prototype._setColumnGrouping = function (colIndex, data) {
|
248
|
+
var colData = this._newColumnData(colIndex);
|
249
|
+
colData["columnGrouping"] = data;
|
250
|
+
};
|
251
|
+
/** @private
|
252
|
+
* @param {number} colIndex
|
253
|
+
* @return {Object}
|
254
|
+
*/
|
255
|
+
ColumnGroupingPlugin.prototype._getColumnGrouping = function (colIndex) {
|
256
|
+
return this._getColumnOption(colIndex, "columnGrouping");
|
257
|
+
};
|
258
|
+
|
228
259
|
/** Legacy group structure from composite grid will be converted to the new structure
|
229
260
|
* @private
|
230
261
|
* @param {Object.<string, Array>} objMap
|
@@ -274,7 +305,7 @@ ColumnGroupingPlugin.prototype._migrateLegacyStructure = function (colModels) {
|
|
274
305
|
|
275
306
|
// Add new definitions and structure to the given legacy objects
|
276
307
|
for (i = 0; i < groupCount; ++i) {
|
277
|
-
groupDef = legacyColumnGroups[i];
|
308
|
+
groupDef = cloneObject(legacyColumnGroups[i]);
|
278
309
|
if (groupDef && groupDef.id) {
|
279
310
|
// WARNING: Modify user's object
|
280
311
|
var childAry = groupMap[groupDef.id];
|
@@ -313,6 +344,7 @@ ColumnGroupingPlugin.prototype._applyGrouping = function () {
|
|
313
344
|
for (r = 0; r < rowCount; r++) {
|
314
345
|
cell = section.getCell(c, r, false);
|
315
346
|
if (cell) {
|
347
|
+
cell.reset();
|
316
348
|
cell.removeClass("no-sort");
|
317
349
|
cell.removeAttribute("group-id");
|
318
350
|
}
|
@@ -333,6 +365,173 @@ ColumnGroupingPlugin.prototype._applyGrouping = function () {
|
|
333
365
|
}
|
334
366
|
}
|
335
367
|
};
|
368
|
+
/** @private
|
369
|
+
*/
|
370
|
+
ColumnGroupingPlugin.prototype._evaluateGroupStructure = function () {
|
371
|
+
// Clear existing group structure
|
372
|
+
var groupMap = this._groupMap = {};
|
373
|
+
var childToParent = this._childToParent = {};
|
374
|
+
var visibleGroupMap = this._visibleGroupMap = {};
|
375
|
+
this._maxDepth = -1;
|
376
|
+
|
377
|
+
// Flatten tree structure to simple dictionary
|
378
|
+
var groupDefs = this._groupDefs;
|
379
|
+
var len = groupDefs.length;
|
380
|
+
var i;
|
381
|
+
for (i = 0; i < len; i++) {
|
382
|
+
this._flattenGroupDefs(groupDefs[i], groupDefs);
|
383
|
+
}
|
384
|
+
|
385
|
+
// Create group map
|
386
|
+
var groupDef;
|
387
|
+
len = groupDefs.length; // length can be changed after flattening
|
388
|
+
for (i = 0; i < len; i++) {
|
389
|
+
groupDef = groupDefs[i];
|
390
|
+
groupMap[groupDef.id] = groupDef;
|
391
|
+
|
392
|
+
// Clone group definitions for rendering
|
393
|
+
visibleGroupMap[groupDef.id] = cloneObject(groupDef);
|
394
|
+
visibleGroupMap[groupDef.id].children = groupDef.children.slice();
|
395
|
+
}
|
396
|
+
|
397
|
+
// Create child to parent map
|
398
|
+
var gid, children, member;
|
399
|
+
for (gid in groupMap) {
|
400
|
+
groupDef = groupMap[gid];
|
401
|
+
children = groupDef.children;
|
402
|
+
for (i = 0; i < children.length; i++) {
|
403
|
+
member = children[i];
|
404
|
+
childToParent[member] = gid;
|
405
|
+
}
|
406
|
+
}
|
407
|
+
|
408
|
+
// Apply a parent id to group definition to make it easier to find depth
|
409
|
+
var parentId;
|
410
|
+
for (gid in visibleGroupMap) {
|
411
|
+
parentId = childToParent[gid];
|
412
|
+
if (parentId) {
|
413
|
+
visibleGroupMap[gid].parent = parentId;
|
414
|
+
groupMap[gid].parent = parentId;
|
415
|
+
}
|
416
|
+
}
|
417
|
+
|
418
|
+
// Filter invisible groups out
|
419
|
+
var rootGroup = [];
|
420
|
+
for (gid in visibleGroupMap) {
|
421
|
+
groupDef = visibleGroupMap[gid];
|
422
|
+
if (this._findGroupTreeDepth(groupDef, 1) === 1) {
|
423
|
+
rootGroup.push(groupDef);
|
424
|
+
}
|
425
|
+
}
|
426
|
+
len = rootGroup.length;
|
427
|
+
for (i = 0; i < len; i++) {
|
428
|
+
this._verifySingleChild(rootGroup[i]);
|
429
|
+
}
|
430
|
+
|
431
|
+
// Determine the depth of each group
|
432
|
+
var depth;
|
433
|
+
for (gid in visibleGroupMap) {
|
434
|
+
groupDef = visibleGroupMap[gid];
|
435
|
+
depth = this._findGroupTreeDepth(groupDef, 1);
|
436
|
+
groupDef["onRow"] = depth - 1;
|
437
|
+
}
|
438
|
+
|
439
|
+
// Calculate the maximum depth
|
440
|
+
var maxDepth = -1;
|
441
|
+
for (gid in visibleGroupMap) {
|
442
|
+
groupDef = visibleGroupMap[gid];
|
443
|
+
depth = groupDef["onRow"];
|
444
|
+
if (depth > maxDepth) {
|
445
|
+
maxDepth = depth;
|
446
|
+
}
|
447
|
+
}
|
448
|
+
this._maxDepth = maxDepth + 1; // Column header depth = maximum group depth + 1
|
449
|
+
};
|
450
|
+
|
451
|
+
/** Flatten group definition structure by using group ID instead of nested group definitions.
|
452
|
+
* @private
|
453
|
+
* @param {Object} groupDef
|
454
|
+
* @param {Array} groupDefs
|
455
|
+
*/
|
456
|
+
ColumnGroupingPlugin.prototype._flattenGroupDefs = function (groupDef, groupDefs) {
|
457
|
+
if (groupDef && groupDef.children) {
|
458
|
+
var children = groupDef.children;
|
459
|
+
var member, groupId;
|
460
|
+
for (var i = 0; i < children.length; i++) {
|
461
|
+
member = children[i];
|
462
|
+
if (typeof member !== "string") {
|
463
|
+
// member is nested group definition
|
464
|
+
groupId = member.id;
|
465
|
+
if (groupId) {
|
466
|
+
children[i] = groupId; // Use group ID instead of nested group definition
|
467
|
+
if (groupDefs.indexOf(member) < 0) {
|
468
|
+
groupDefs.push(member);
|
469
|
+
}
|
470
|
+
this._flattenGroupDefs(member, groupDefs);
|
471
|
+
}
|
472
|
+
}
|
473
|
+
}
|
474
|
+
}
|
475
|
+
};
|
476
|
+
|
477
|
+
/** @private
|
478
|
+
* @param {Object} groupDef
|
479
|
+
* @param {number} currentDepth
|
480
|
+
* @return {number}
|
481
|
+
*/
|
482
|
+
ColumnGroupingPlugin.prototype._findGroupTreeDepth = function (groupDef, currentDepth) {
|
483
|
+
var parentId = groupDef["parent"];
|
484
|
+
var parentNode = this._visibleGroupMap[parentId];
|
485
|
+
if (parentNode) {
|
486
|
+
return this._findGroupTreeDepth(parentNode, currentDepth + 1);
|
487
|
+
} else {
|
488
|
+
return currentDepth;
|
489
|
+
}
|
490
|
+
};
|
491
|
+
|
492
|
+
/** @private
|
493
|
+
* @param {Object} groupDef
|
494
|
+
* @return {boolean}
|
495
|
+
*/
|
496
|
+
ColumnGroupingPlugin.prototype._verifySingleChild = function (groupDef) {
|
497
|
+
var children = groupDef.children;
|
498
|
+
var visibleChildCount = 0;
|
499
|
+
var visibleChildGroupCount = 0;
|
500
|
+
var invisibleMembers = [];
|
501
|
+
var i, member;
|
502
|
+
for (i = 0; i < children.length; i++) {
|
503
|
+
member = children[i];
|
504
|
+
if (this._visibleGroupMap[member]) {
|
505
|
+
if (this._verifySingleChild(this._visibleGroupMap[member])) {
|
506
|
+
++visibleChildCount;
|
507
|
+
++visibleChildGroupCount;
|
508
|
+
} else {
|
509
|
+
invisibleMembers.push(member);
|
510
|
+
}
|
511
|
+
} else {
|
512
|
+
if (this._getColumnIndexById(member) > -1) {
|
513
|
+
++visibleChildCount;
|
514
|
+
} else {
|
515
|
+
invisibleMembers.push(member);
|
516
|
+
}
|
517
|
+
}
|
518
|
+
}
|
519
|
+
|
520
|
+
// Remove invisible members, keep only visible members
|
521
|
+
if (invisibleMembers.length) {
|
522
|
+
for (i = 0; i < invisibleMembers.length; i++) {
|
523
|
+
member = invisibleMembers[i];
|
524
|
+
groupDef.children.splice(children.indexOf(member), 1);
|
525
|
+
}
|
526
|
+
}
|
527
|
+
if (visibleChildCount > 1 || visibleChildGroupCount > 1) {
|
528
|
+
return true;
|
529
|
+
} else {
|
530
|
+
delete this._visibleGroupMap[groupDef.id];
|
531
|
+
return false;
|
532
|
+
}
|
533
|
+
};
|
534
|
+
|
336
535
|
/** Set a timer to call applyGrouping only once to avoid performance issue
|
337
536
|
* @private
|
338
537
|
*/
|
@@ -404,7 +603,7 @@ ColumnGroupingPlugin.prototype._spanGroupVertically = function (titleSection) {
|
|
404
603
|
*/
|
405
604
|
ColumnGroupingPlugin.prototype._spanGroupHorizontally = function (titleSection) {
|
406
605
|
var section = titleSection;
|
407
|
-
var groupTable = this.
|
606
|
+
var groupTable = this._visibleGroupMap;
|
408
607
|
|
409
608
|
// Span column of column group
|
410
609
|
for (var id in groupTable) {
|
@@ -427,7 +626,7 @@ ColumnGroupingPlugin.prototype._spanGroupHorizontally = function (titleSection)
|
|
427
626
|
*/
|
428
627
|
ColumnGroupingPlugin.prototype._renderGroups = function () {
|
429
628
|
var hostCount = this._hosts.length;
|
430
|
-
var groupMap = this.
|
629
|
+
var groupMap = this._visibleGroupMap;
|
431
630
|
for (var i = 0; i < hostCount; ++i) {
|
432
631
|
var section = this._hosts[i].getSection("title");
|
433
632
|
if (!section) {
|
@@ -515,8 +714,8 @@ ColumnGroupingPlugin.prototype._applyTimeSeries = function (e) {
|
|
515
714
|
var parentName = tsParentDef.getName();
|
516
715
|
var parentId = tsParentDef.getId();
|
517
716
|
var groupId = "timeSerieGroup_" + parentId;
|
518
|
-
var
|
519
|
-
if (
|
717
|
+
var groupDef = this._groupMap[groupId];
|
718
|
+
if (groupDef) {
|
520
719
|
// add children time series field to parent
|
521
720
|
for (i = 0; i < children.length; i++) {
|
522
721
|
var child = children[i];
|
@@ -581,6 +780,31 @@ ColumnGroupingPlugin.prototype._onColumnMoved = function (e) {
|
|
581
780
|
/** @private
|
582
781
|
* @param {Object} e
|
583
782
|
*/
|
783
|
+
ColumnGroupingPlugin.prototype._onColumnRemoved = function (e) {
|
784
|
+
var colData = e.columnData;
|
785
|
+
if (colData && colData.columnGrouping) {
|
786
|
+
var colId = colData.columnGrouping.id;
|
787
|
+
var groupId = this._childToParent[colId];
|
788
|
+
if (groupId) {
|
789
|
+
var groupDef = this._groupMap[groupId];
|
790
|
+
if (groupDef) {
|
791
|
+
var children = groupDef.children;
|
792
|
+
var index = children.indexOf(colId);
|
793
|
+
if (index > -1) {
|
794
|
+
if (children.length < 3) {
|
795
|
+
this._groupDefs.splice(this._groupDefs.indexOf(groupDef), 1);
|
796
|
+
} else {
|
797
|
+
children.splice(index, 1);
|
798
|
+
}
|
799
|
+
this._requestApplyGrouping();
|
800
|
+
}
|
801
|
+
}
|
802
|
+
}
|
803
|
+
}
|
804
|
+
};
|
805
|
+
/** @private
|
806
|
+
* @param {Object} e
|
807
|
+
*/
|
584
808
|
ColumnGroupingPlugin.prototype._onBeforeColumnBoundUpdate = function (e) {
|
585
809
|
var selectedColumns = e.selectedColumns;
|
586
810
|
var parentMap = this._childToParent;
|
@@ -721,6 +945,7 @@ ColumnGroupingPlugin.prototype.removeGroup = function (groupId) {
|
|
721
945
|
*/
|
722
946
|
ColumnGroupingPlugin.prototype.setGroupDefinitions = function (groupDefs) {
|
723
947
|
if (Array.isArray(groupDefs)) {
|
948
|
+
groupDefs = groupDefs.map(ColumnGroupingPlugin._cloneObject);
|
724
949
|
groupDefs = groupDefs.filter(ColumnGroupingPlugin._isValidGroup);
|
725
950
|
if (!groupDefs.length) {
|
726
951
|
groupDefs = null;
|
@@ -777,6 +1002,7 @@ ColumnGroupingPlugin.prototype.setGroupDefinition = function (groupId, newDef) {
|
|
777
1002
|
var curDef = this.getGroupDefinition(groupId);
|
778
1003
|
if (curDef) {
|
779
1004
|
var at = this._groupDefs.indexOf(curDef);
|
1005
|
+
newDef = cloneObject(newDef);
|
780
1006
|
newDef.id = groupId;
|
781
1007
|
this._groupDefs[at] = newDef;
|
782
1008
|
this._applyGrouping();
|
@@ -832,11 +1058,11 @@ ColumnGroupingPlugin.prototype.getChildColumnIndices = function (groupId) {
|
|
832
1058
|
if (group) {
|
833
1059
|
var colIds = this._getGroupMembers(group);
|
834
1060
|
var colIndices = [];
|
835
|
-
var
|
1061
|
+
var index;
|
836
1062
|
for (var i = 0; i < colIds.length; i++) {
|
837
|
-
|
838
|
-
if (
|
839
|
-
colIndices.push(
|
1063
|
+
index = this.getColumnIndex(colIds[i]);
|
1064
|
+
if (index > -1) {
|
1065
|
+
colIndices.push(index);
|
840
1066
|
}
|
841
1067
|
}
|
842
1068
|
return colIndices.sort();
|
@@ -860,7 +1086,7 @@ ColumnGroupingPlugin.prototype.getGroupIds = function (colRef) {
|
|
860
1086
|
var groupIds = [groupId];
|
861
1087
|
var group = this._groupMap[groupId];
|
862
1088
|
while (group && group.parent) {
|
863
|
-
group = this.
|
1089
|
+
group = this._groupMap[group.parent];
|
864
1090
|
if (group) {
|
865
1091
|
groupIds.push(group.id);
|
866
1092
|
}
|
@@ -886,7 +1112,7 @@ ColumnGroupingPlugin.prototype.getMaxGroupLevel = function () {
|
|
886
1112
|
* @return {number}
|
887
1113
|
*/
|
888
1114
|
ColumnGroupingPlugin.prototype.getGroupLevel = function (groupId) {
|
889
|
-
var group = this.
|
1115
|
+
var group = this._visibleGroupMap[groupId];
|
890
1116
|
if (group) {
|
891
1117
|
return group.onRow;
|
892
1118
|
}
|
@@ -927,106 +1153,11 @@ ColumnGroupingPlugin.prototype._getRootGroup = function (groupId) {
|
|
927
1153
|
}
|
928
1154
|
var group = this._groupMap[groupId];
|
929
1155
|
while (group.parent) {
|
930
|
-
group = this.
|
1156
|
+
group = this._groupMap[group.parent];
|
931
1157
|
}
|
932
1158
|
return group;
|
933
1159
|
};
|
934
1160
|
|
935
|
-
/** @private
|
936
|
-
*/
|
937
|
-
ColumnGroupingPlugin.prototype._evaluateGroupStructure = function () {
|
938
|
-
// Clear existing group structure
|
939
|
-
this._groupMap = {};
|
940
|
-
this._childToParent = {};
|
941
|
-
this._maxDepth = -1;
|
942
|
-
|
943
|
-
// Flatten tree to dictionary
|
944
|
-
var columnGroups = this._groupDefs;
|
945
|
-
var inUsedGroup = {};
|
946
|
-
var node;
|
947
|
-
for (var cg = 0; cg < columnGroups.length; cg++) {
|
948
|
-
// node can be a root or child
|
949
|
-
node = columnGroups[cg];
|
950
|
-
// skip tree that don't have a child
|
951
|
-
if (node.children && node.children.length) {
|
952
|
-
this._flattenTree(node, inUsedGroup);
|
953
|
-
}
|
954
|
-
}
|
955
|
-
var id;
|
956
|
-
// Apply parent id to columnGroup for easy to find depth
|
957
|
-
for (id in this._groupMap) {
|
958
|
-
node = this._groupMap[id];
|
959
|
-
if (this._childToParent[node.id]) {
|
960
|
-
var parentId = this._childToParent[node.id];
|
961
|
-
node["parent"] = parentId;
|
962
|
-
}
|
963
|
-
}
|
964
|
-
|
965
|
-
// find depth of each group
|
966
|
-
for (id in this._groupMap) {
|
967
|
-
node = this._groupMap[id];
|
968
|
-
var depth = this._findGroupTreeDepth(node, 1);
|
969
|
-
node["onRow"] = depth - 1; // Modify user's object
|
970
|
-
}
|
971
|
-
|
972
|
-
// Calculate max depth
|
973
|
-
var maxDepth = 0;
|
974
|
-
for (id in this._groupMap) {
|
975
|
-
node = this._groupMap[id];
|
976
|
-
depth = node["onRow"] + 1;
|
977
|
-
if (depth > maxDepth) {
|
978
|
-
maxDepth = depth;
|
979
|
-
}
|
980
|
-
}
|
981
|
-
this._maxDepth = maxDepth;
|
982
|
-
};
|
983
|
-
/** @private
|
984
|
-
* @param {Object} node
|
985
|
-
* @param {boolean} inUsedGroup
|
986
|
-
*/
|
987
|
-
ColumnGroupingPlugin.prototype._flattenTree = function (node, inUsedGroup) {
|
988
|
-
var childrens = node.children;
|
989
|
-
if (childrens && childrens.length > 0) {
|
990
|
-
var childId;
|
991
|
-
for (var c = 0; c < childrens.length; c++) {
|
992
|
-
var child = childrens[c];
|
993
|
-
if (child.id) {
|
994
|
-
// child is group object
|
995
|
-
childId = child.id;
|
996
|
-
this._flattenTree(child, inUsedGroup);
|
997
|
-
} else {
|
998
|
-
// child can be column id or group id
|
999
|
-
childId = child;
|
1000
|
-
if (inUsedGroup[childId] || this._getColumnIndexById(childId) !== -1) {
|
1001
|
-
inUsedGroup[node.id] = true;
|
1002
|
-
}
|
1003
|
-
}
|
1004
|
-
if (!this._childToParent[childId] && childId != node.id) {
|
1005
|
-
this._childToParent[childId] = node.id;
|
1006
|
-
}
|
1007
|
-
}
|
1008
|
-
|
1009
|
-
// Create Tree node for only in-used group
|
1010
|
-
if (!this._groupMap[node.id] && inUsedGroup[node.id]) {
|
1011
|
-
this._groupMap[node.id] = cloneObject(node); // clone node
|
1012
|
-
}
|
1013
|
-
}
|
1014
|
-
};
|
1015
|
-
/** @private
|
1016
|
-
* @param {Object} node
|
1017
|
-
* @param {number} currentDepth
|
1018
|
-
* @return {number}
|
1019
|
-
*/
|
1020
|
-
ColumnGroupingPlugin.prototype._findGroupTreeDepth = function (node, currentDepth) {
|
1021
|
-
var parentId = node["parent"];
|
1022
|
-
var parentNode = this._groupMap[parentId];
|
1023
|
-
if (parentNode) {
|
1024
|
-
return this._findGroupTreeDepth(parentNode, currentDepth + 1);
|
1025
|
-
} else {
|
1026
|
-
return currentDepth;
|
1027
|
-
}
|
1028
|
-
};
|
1029
|
-
|
1030
1161
|
/** This version exclude invisible column unlike the one in GridPlugin
|
1031
1162
|
* @private
|
1032
1163
|
* @param {string} id
|
@@ -1056,20 +1187,20 @@ ColumnGroupingPlugin.prototype._findColumnIndexArr = function (node, cluster) {
|
|
1056
1187
|
for (var i = 0; i < childrens.length; i++) {
|
1057
1188
|
var child = childrens[i];
|
1058
1189
|
if (!child.id) {
|
1059
|
-
if (!this.
|
1190
|
+
if (!this._visibleGroupMap[child]) {
|
1060
1191
|
var colIndex = this._getColumnIndexById(child);
|
1061
1192
|
if (colIndex !== -1) {
|
1062
1193
|
cluster.push(colIndex);
|
1063
1194
|
}
|
1064
1195
|
} else {
|
1065
|
-
this._findColumnIndexArr(this.
|
1196
|
+
this._findColumnIndexArr(this._visibleGroupMap[child], cluster);
|
1066
1197
|
}
|
1067
1198
|
} else {
|
1068
1199
|
// skip children that has same id as parent
|
1069
1200
|
if (child.id === node.id) {
|
1070
1201
|
return;
|
1071
1202
|
}
|
1072
|
-
this._findColumnIndexArr(this.
|
1203
|
+
this._findColumnIndexArr(this._visibleGroupMap[child.id], cluster);
|
1073
1204
|
}
|
1074
1205
|
}
|
1075
1206
|
}
|
@@ -1123,11 +1254,10 @@ ColumnGroupingPlugin._groupConsecutiveArr = function (arr) {
|
|
1123
1254
|
* @param {string} groupId
|
1124
1255
|
*/
|
1125
1256
|
ColumnGroupingPlugin.prototype._addGroupChild = function (childId, groupId) {
|
1126
|
-
var groupDef = this.
|
1257
|
+
var groupDef = this._groupMap[groupId];
|
1127
1258
|
if (childId && groupDef) {
|
1128
1259
|
var chdr = groupDef.children;
|
1129
1260
|
if (chdr && chdr.indexOf(childId) < 0) {
|
1130
|
-
this._childToParent[childId] = groupId;
|
1131
1261
|
chdr.push(childId);
|
1132
1262
|
}
|
1133
1263
|
}
|
@@ -1137,7 +1267,7 @@ ColumnGroupingPlugin.prototype._addGroupChild = function (childId, groupId) {
|
|
1137
1267
|
* @return {ColumnGroupingPlugin~GroupDefinition}
|
1138
1268
|
*/
|
1139
1269
|
ColumnGroupingPlugin.prototype._getParentGroup = function (childId) {
|
1140
|
-
return this.
|
1270
|
+
return this._visibleGroupMap[this._childToParent[childId]];
|
1141
1271
|
};
|
1142
1272
|
/** @private
|
1143
1273
|
* @param {string} colId
|
@@ -1195,16 +1325,16 @@ ColumnGroupingPlugin.prototype.getCellInfo = function (e) {
|
|
1195
1325
|
return cellInfo;
|
1196
1326
|
};
|
1197
1327
|
/** @public
|
1198
|
-
* @param {number|string}
|
1328
|
+
* @param {number|string} colRef //Column index or id that should be moved
|
1199
1329
|
* @param {number} to
|
1200
1330
|
* @param {string} groupId
|
1201
1331
|
*/
|
1202
|
-
ColumnGroupingPlugin.prototype.moveColumnIntoGroup = function (
|
1332
|
+
ColumnGroupingPlugin.prototype.moveColumnIntoGroup = function (colRef, to, groupId) {
|
1203
1333
|
var fromIndex = -1;
|
1204
|
-
if (typeof
|
1205
|
-
fromIndex = this._getColumnIndexById(
|
1334
|
+
if (typeof colRef == "string") {
|
1335
|
+
fromIndex = this._getColumnIndexById(colRef);
|
1206
1336
|
} else {
|
1207
|
-
fromIndex =
|
1337
|
+
fromIndex = colRef;
|
1208
1338
|
}
|
1209
1339
|
if (fromIndex == -1) {
|
1210
1340
|
return;
|
@@ -1280,17 +1410,17 @@ ColumnGroupingPlugin.prototype.moveColumnIntoGroup = function (from, to, groupId
|
|
1280
1410
|
this._requestApplyGrouping();
|
1281
1411
|
};
|
1282
1412
|
/** @public
|
1283
|
-
* @param {number|string}
|
1413
|
+
* @param {number|string} colRef //Column index or id that should be moved
|
1284
1414
|
* @param {string} groupId
|
1285
1415
|
*/
|
1286
|
-
ColumnGroupingPlugin.prototype.setColumnParent = function (
|
1416
|
+
ColumnGroupingPlugin.prototype.setColumnParent = function (colRef, groupId) {
|
1287
1417
|
var api = this.getGridApi();
|
1288
1418
|
if (!api) {
|
1289
1419
|
return;
|
1290
1420
|
}
|
1291
1421
|
var grid = this._hosts[0];
|
1292
1422
|
var colCount = grid.getColumnCount();
|
1293
|
-
this.moveColumnIntoGroup(
|
1423
|
+
this.moveColumnIntoGroup(colRef, colCount, groupId);
|
1294
1424
|
};
|
1295
1425
|
export default ColumnGroupingPlugin;
|
1296
1426
|
export { ColumnGroupingPlugin, ColumnGroupingPlugin as ColumnGrouping, ColumnGroupingPlugin as ColumnGroupingExtension };
|
@@ -11,7 +11,8 @@ declare namespace ColumnStackPlugin {
|
|
11
11
|
|
12
12
|
type Options = {
|
13
13
|
fields: (string)[]|null,
|
14
|
-
stacks: (ColumnStackPlugin.StackDefinition)[]|null
|
14
|
+
stacks: (ColumnStackPlugin.StackDefinition)[]|null,
|
15
|
+
autoStacking?: boolean|null
|
15
16
|
};
|
16
17
|
|
17
18
|
type ColumnOptions = {
|
@@ -30,6 +31,7 @@ declare namespace ColumnStackPlugin {
|
|
30
31
|
spreading?: boolean|null,
|
31
32
|
collapsed?: boolean|null,
|
32
33
|
children: (string)[]|null,
|
34
|
+
fields: (string)[]|null,
|
33
35
|
name?: string|null,
|
34
36
|
activeColumn?: string|null
|
35
37
|
};
|
@@ -100,6 +102,8 @@ declare class ColumnStackPlugin extends GridPlugin {
|
|
100
102
|
|
101
103
|
public getColumnIndicesByColumnIds(columnId: string|(string)[]|null): (string)[];
|
102
104
|
|
105
|
+
public getColumnIdsByFields(field: string|(string)[]|null): (string)[];
|
106
|
+
|
103
107
|
public addColumnToStack(colRef: number|string|null, stackId: string): void;
|
104
108
|
|
105
109
|
public removeColumnFromStack(colRef: number|string|null): void;
|
@@ -110,6 +114,8 @@ declare class ColumnStackPlugin extends GridPlugin {
|
|
110
114
|
|
111
115
|
public getStackName(stackId: string): string;
|
112
116
|
|
117
|
+
public getActiveColumnField(stackId: string): string;
|
118
|
+
|
113
119
|
}
|
114
120
|
|
115
121
|
export default ColumnStackPlugin;
|