@refinitiv-ui/efx-grid 6.0.41 → 6.0.42
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/core/dist/core.js +837 -871
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/grid/Core.d.ts +4 -0
- package/lib/core/es6/grid/Core.js +67 -2
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.d.ts +3 -2
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +26 -26
- package/lib/core/es6/grid/util/util.js +25 -9
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +212 -44
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.d.ts +22 -0
- package/lib/rt-grid/es6/Grid.js +91 -4
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +4 -0
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +34 -19
- package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +9 -3
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +290 -364
- package/lib/tr-grid-util/es6/DateTime.js +3 -3
- package/lib/tr-grid-util/es6/GridPlugin.js +1 -1
- package/lib/types/es6/ColumnGrouping.d.ts +4 -0
- package/lib/types/es6/ColumnStack.d.ts +9 -3
- package/lib/types/es6/Core/grid/Core.d.ts +4 -0
- package/lib/types/es6/Core/grid/plugins/SortableTitlePlugin.d.ts +3 -2
- package/lib/versions.json +3 -3
- package/package.json +1 -1
@@ -12,7 +12,7 @@ import { preventDefault } from "../../tr-grid-util/es6/EventDispatcher.js";
|
|
12
12
|
* @description Available options describing `columnStack` object specified in grid's option
|
13
13
|
* @property {Array.<string>} fields Fields for stacking. The minimum is 2 fields.
|
14
14
|
* @property {Array.<ColumnStackPlugin~StackDefinition>} stacks List of stacking configuration
|
15
|
-
* @property {boolean=} autoStacking
|
15
|
+
* @property {boolean=} autoStacking Deprecated. Stacks are automatically maintained as long as its members exist
|
16
16
|
* @property {Function=} clicked=null Event handler when user clicks on stack/expanding icon
|
17
17
|
*/
|
18
18
|
|
@@ -31,13 +31,13 @@ import { preventDefault } from "../../tr-grid-util/es6/EventDispatcher.js";
|
|
31
31
|
|
32
32
|
/** @typedef {Object} ColumnStackPlugin~StackDefinition
|
33
33
|
* @description Available options for setting stack
|
34
|
-
* @property {string} id Group
|
34
|
+
* @property {string} id Group Id
|
35
35
|
* @property {boolean=} spreading=false If specified true, this group will be running in collapsing mode
|
36
36
|
* @property {boolean=} collapsed=true If disabled, this group will be expanded at the first time
|
37
|
-
* @property {Array.<string
|
38
|
-
* @property {Array.<string
|
37
|
+
* @property {Array.<string>=} children=null List of column Ids for the stack members. String in this array is assumed to be column ids
|
38
|
+
* @property {Array.<string>=} fields=null List of column fields for the stack members. This will override children property
|
39
39
|
* @property {string=} name="" Name defined for specific stack
|
40
|
-
* @property {string=} activeColumn=""
|
40
|
+
* @property {string=} activeColumn="" Column Id or field of the active column.
|
41
41
|
*/
|
42
42
|
|
43
43
|
/** @typedef {Object} ColumnStackPlugin~StackConfiguration
|
@@ -61,30 +61,35 @@ import { preventDefault } from "../../tr-grid-util/es6/EventDispatcher.js";
|
|
61
61
|
|
62
62
|
/** @private
|
63
63
|
* @function
|
64
|
-
* @param {
|
65
|
-
* @param {
|
64
|
+
* @param {Object} indexMap
|
65
|
+
* @param {*} refA
|
66
|
+
* @param {*} refB
|
66
67
|
* @return {number}
|
67
68
|
*/
|
68
|
-
var
|
69
|
-
var
|
70
|
-
var
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
if(invalidA) {
|
75
|
-
return invalidB ? 0 : 1;
|
76
|
-
} else if(invalidB) {
|
77
|
-
return -1;
|
78
|
-
}
|
79
|
-
if(valA < valB) {
|
80
|
-
return -1;
|
69
|
+
var _indexSorter = function(indexMap, refA, refB) {
|
70
|
+
var numA = indexMap[refA];
|
71
|
+
var numB = indexMap[refB];
|
72
|
+
if(numA === numB) {
|
73
|
+
return 0;
|
81
74
|
}
|
82
|
-
if(
|
75
|
+
if(numA < 0) {
|
83
76
|
return 1;
|
84
77
|
}
|
85
|
-
|
86
|
-
|
78
|
+
if(numB < 0) {
|
79
|
+
return -1;
|
80
|
+
}
|
81
|
+
return numA - numB;
|
87
82
|
};
|
83
|
+
/** @private
|
84
|
+
* @function
|
85
|
+
* @param {Object} indexMap
|
86
|
+
* @param {*} refA
|
87
|
+
* @return {boolean}
|
88
|
+
*/
|
89
|
+
var _byValidIndex = function(indexMap, refA) {
|
90
|
+
return indexMap[refA] >= 0;
|
91
|
+
};
|
92
|
+
|
88
93
|
/** @private
|
89
94
|
* @description Resolve active column from the given stack object, if activeColumn is invalid
|
90
95
|
* @param {Object} stackOpt
|
@@ -95,7 +100,6 @@ var _resolveActiveColumn = function(stackOpt) {
|
|
95
100
|
var children = stackOpt.children;
|
96
101
|
if(children && children.length) {
|
97
102
|
var activeColumn = stackOpt.activeColumn;
|
98
|
-
// TODO: If columns are stored as column id and activeColumn is a field, active index could not be found
|
99
103
|
if(!activeColumn || children.indexOf(activeColumn) < 0) {
|
100
104
|
stackOpt.activeColumn = stackOpt.spreading ? children[children.length - 1] : children[0];
|
101
105
|
return true;
|
@@ -119,14 +123,12 @@ var ColumnStackPlugin = function () {
|
|
119
123
|
|
120
124
|
this._onStackButtonClicked = this._onStackButtonClicked.bind(this);
|
121
125
|
this._updateUI = this._updateUI.bind(this);
|
122
|
-
this.
|
123
|
-
this._toIdOrField = this._toIdOrField.bind(this);
|
126
|
+
this._toColumnId = this._toColumnId.bind(this);
|
124
127
|
|
125
128
|
this._hosts = [];
|
126
129
|
this._groupDefs = new GroupDefinitions();
|
127
130
|
|
128
131
|
this._conflator = new Conflator(50, this._updateUI);
|
129
|
-
this._stackConflator = new Conflator(100, this._requestStackingByFields);
|
130
132
|
};
|
131
133
|
|
132
134
|
Ext.inherits(ColumnStackPlugin, GridPlugin);
|
@@ -139,23 +141,20 @@ ColumnStackPlugin.prototype._groupDefs;
|
|
139
141
|
* @private
|
140
142
|
*/
|
141
143
|
ColumnStackPlugin.prototype._pendingStacks;
|
142
|
-
/**
|
143
|
-
* @type {Object}
|
144
|
+
/** @type {Object.<string, string>}
|
144
145
|
* @private
|
145
146
|
*/
|
146
|
-
ColumnStackPlugin.prototype.
|
147
|
+
ColumnStackPlugin.prototype._usingField = false;
|
148
|
+
|
147
149
|
/** @type {boolean}
|
148
150
|
* @private
|
149
151
|
*/
|
150
152
|
ColumnStackPlugin.prototype._updating = false;
|
151
|
-
|
152
|
-
|
153
|
-
*/
|
154
|
-
ColumnStackPlugin.prototype._autoStacking = false;
|
155
|
-
/** @type {boolean}
|
153
|
+
|
154
|
+
/** @type {number}
|
156
155
|
* @private
|
157
156
|
*/
|
158
|
-
ColumnStackPlugin.prototype._inReordering =
|
157
|
+
ColumnStackPlugin.prototype._inReordering = 0;
|
159
158
|
/** @type {boolean}
|
160
159
|
* @private
|
161
160
|
*/
|
@@ -243,7 +242,6 @@ ColumnStackPlugin.prototype.unload = function (host) {
|
|
243
242
|
|
244
243
|
if(this._hosts.length <= 0) {
|
245
244
|
this._conflator.reset();
|
246
|
-
this._stackConflator.reset();
|
247
245
|
this._groupDefs.removeAllGroups();
|
248
246
|
}
|
249
247
|
this._dispose();
|
@@ -307,23 +305,18 @@ ColumnStackPlugin.prototype.config = function (options) {
|
|
307
305
|
var stackConfig = null;
|
308
306
|
if(columnStack) {
|
309
307
|
this.addListener(columnStack, "clicked");
|
310
|
-
|
311
|
-
if(columnStack.autoStacking != null) {
|
312
|
-
this._autoStacking = columnStack.autoStacking;
|
313
|
-
}
|
308
|
+
this._usingField = false;
|
314
309
|
|
315
310
|
if(columnStack.fields && columnStack.fields.length > 1) {
|
311
|
+
this._usingField = true;
|
312
|
+
|
316
313
|
hasStack = true;
|
317
314
|
stackId = this._generateStackId(); // TODO: Stack id may need to be hardcoded
|
318
|
-
if(!this._idToFields) {
|
319
|
-
this._idToFields = {};
|
320
|
-
}
|
321
|
-
this._idToFields[stackId] = columnStack.fields;
|
322
315
|
stacks[stackId] = {
|
323
316
|
id: stackId,
|
324
317
|
spreading: columnStack.spreading === true,
|
325
318
|
collapsed: columnStack.collapsed !== false,
|
326
|
-
|
319
|
+
fields: columnStack.fields
|
327
320
|
};
|
328
321
|
} else if (columnStack.stacks && columnStack.stacks.length) {
|
329
322
|
hasStack = true;
|
@@ -331,7 +324,7 @@ ColumnStackPlugin.prototype.config = function (options) {
|
|
331
324
|
for(i = 0; i < stackLen; i++){
|
332
325
|
stackConfig = columnStack.stacks[i];
|
333
326
|
stackId = stackConfig.id || this._generateStackId();
|
334
|
-
if(stackConfig.collapsed == null){
|
327
|
+
if(stackConfig.collapsed == null){ // TODO: consolidate with the above
|
335
328
|
stackConfig.collapsed = true;
|
336
329
|
}
|
337
330
|
if(stackConfig.spreading == null){
|
@@ -365,7 +358,7 @@ ColumnStackPlugin.prototype.config = function (options) {
|
|
365
358
|
}
|
366
359
|
if(stackId) {
|
367
360
|
stackOpt = stacks[stackId];
|
368
|
-
if(!stackOpt
|
361
|
+
if(!stackOpt) {
|
369
362
|
stackOpt = stacks[stackId] = {
|
370
363
|
id: stackId,
|
371
364
|
spreading: spreading, // Default is false (stacking mode)
|
@@ -399,50 +392,13 @@ ColumnStackPlugin.prototype.config = function (options) {
|
|
399
392
|
ColumnStackPlugin.prototype.getConfigObject = function (gridOptions) {
|
400
393
|
var obj = gridOptions || {};
|
401
394
|
|
402
|
-
|
403
|
-
var stackOptions =
|
404
|
-
|
405
|
-
for (var stackKey in stacks) {
|
406
|
-
var stackOption = stacks[stackKey];
|
407
|
-
var activeColIndex = this.getColumnIndex(stackOption.activeColumn);
|
408
|
-
|
409
|
-
var stackConfigObj = {
|
410
|
-
id: stackOption.id
|
411
|
-
};
|
412
|
-
var name = stackOption.name;
|
413
|
-
var collapsed = stackOption.collapsed;
|
414
|
-
var spreading = stackOption.spreading;
|
415
|
-
|
416
|
-
if (name) {
|
417
|
-
stackConfigObj.name = name;
|
418
|
-
}
|
419
|
-
if (collapsed !== true) {
|
420
|
-
stackConfigObj.collapsed = collapsed;
|
421
|
-
}
|
422
|
-
if (spreading !== false) {
|
423
|
-
stackConfigObj.spreading = spreading;
|
424
|
-
}
|
425
|
-
|
426
|
-
if (this._autoStacking) {
|
427
|
-
var fields = this._idToFields[stackOption.id];
|
428
|
-
var activeColumnField = this._getField(activeColIndex);
|
429
|
-
|
430
|
-
stackConfigObj.fields = fields;
|
431
|
-
stackConfigObj.activeColumn = activeColumnField;
|
395
|
+
// TODO: Handle the case where pendingStacks has not been applied
|
396
|
+
var stackOptions = this.getStacks();
|
432
397
|
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
stackConfigObj.activeColumn = stackOption.activeColumn; // WARNING: Column Id or field
|
437
|
-
}
|
438
|
-
}
|
439
|
-
stackOptions.push(stackConfigObj);
|
398
|
+
if(stackOptions.length) {
|
399
|
+
obj.columnStack = {};
|
400
|
+
obj.columnStack.stacks = stackOptions;
|
440
401
|
}
|
441
|
-
|
442
|
-
obj.columnStack = {};
|
443
|
-
obj.columnStack.stacks = stackOptions;
|
444
|
-
obj.columnStack.autoStacking = this._autoStacking;
|
445
|
-
|
446
402
|
return obj;
|
447
403
|
};
|
448
404
|
|
@@ -460,44 +416,18 @@ ColumnStackPlugin.prototype._afterInit = function () {
|
|
460
416
|
|
461
417
|
/** @private
|
462
418
|
* @param {*} colRef
|
463
|
-
* @return {string} column id
|
419
|
+
* @return {string} column id
|
464
420
|
*/
|
465
|
-
ColumnStackPlugin.prototype.
|
421
|
+
ColumnStackPlugin.prototype._toColumnId = function(colRef) {
|
466
422
|
if(typeof colRef !== "string") {
|
467
423
|
if(typeof colRef === "number") {
|
468
424
|
return this.getColumnId(colRef);
|
469
|
-
// return this._getField(colRef);
|
470
425
|
}
|
471
426
|
return "";
|
472
427
|
}
|
473
428
|
return colRef || "";
|
474
429
|
};
|
475
430
|
/** @private
|
476
|
-
* @param {Object} stackConfig
|
477
|
-
*/
|
478
|
-
ColumnStackPlugin.prototype._transformStackConfig = function(stackConfig) {
|
479
|
-
var children = stackConfig.children;
|
480
|
-
var childCount = children ? children.length : 0;
|
481
|
-
if(childCount) { // Fields or ids
|
482
|
-
for(var i = 0; i < childCount; i++){
|
483
|
-
var childRef = this._toIdOrField(children[i]);
|
484
|
-
if(childRef) {
|
485
|
-
children[i] = childRef;
|
486
|
-
}
|
487
|
-
}
|
488
|
-
} else if(stackConfig.fields) {
|
489
|
-
stackConfig.children = stackConfig.fields;
|
490
|
-
} else if(!stackConfig.children) {
|
491
|
-
stackConfig.children = [];
|
492
|
-
}
|
493
|
-
if(!this._autoStacking) { // TODO: This may not be necessary
|
494
|
-
var activeColumn = this._toIdOrField(stackConfig.activeColumn);
|
495
|
-
if(activeColumn) {
|
496
|
-
stackConfig.activeColumn = activeColumn;
|
497
|
-
}
|
498
|
-
}
|
499
|
-
};
|
500
|
-
/** @private
|
501
431
|
* @param {Object=} stacks
|
502
432
|
*/
|
503
433
|
ColumnStackPlugin.prototype._applyUserConfigs = function(stacks) {
|
@@ -505,8 +435,13 @@ ColumnStackPlugin.prototype._applyUserConfigs = function(stacks) {
|
|
505
435
|
this.removeAllStacks(false); // No UI update
|
506
436
|
for(var stackId in stacks) {
|
507
437
|
var stack = stacks[stackId];
|
508
|
-
|
509
|
-
|
438
|
+
var children = stack.children;
|
439
|
+
var fields = stack.fields;
|
440
|
+
if(fields) { // Convert all fields and indices to column Ids
|
441
|
+
this._usingField = true;
|
442
|
+
children = fields; // override children with fields
|
443
|
+
}
|
444
|
+
this.stackColumns(children, stackId, stack);
|
510
445
|
}
|
511
446
|
} else {
|
512
447
|
this.removeAllStacks(); // with UI update
|
@@ -518,19 +453,9 @@ ColumnStackPlugin.prototype._applyUserConfigs = function(stacks) {
|
|
518
453
|
* @return {Object}
|
519
454
|
*/
|
520
455
|
ColumnStackPlugin.prototype._getColumnStackOptions = function(colIndex) {
|
521
|
-
|
522
|
-
if(colIndex >= 0 && colIndex < colCount) {
|
456
|
+
if(colIndex >= 0 && colIndex < this.getColumnCount()) {
|
523
457
|
var colId = this.getColumnId(colIndex);
|
524
|
-
|
525
|
-
if(stack) {
|
526
|
-
return stack;
|
527
|
-
}
|
528
|
-
|
529
|
-
var field = this._getField(colIndex);
|
530
|
-
stack = this._groupDefs.getParentGroup(field);
|
531
|
-
if(stack) {
|
532
|
-
return stack;
|
533
|
-
}
|
458
|
+
return this._groupDefs.getParentGroup(colId) || null;
|
534
459
|
}
|
535
460
|
return null;
|
536
461
|
};
|
@@ -590,13 +515,6 @@ ColumnStackPlugin.prototype._moveStackedColumns = function (colRefs) {
|
|
590
515
|
}
|
591
516
|
};
|
592
517
|
/** @private
|
593
|
-
* @return {number}
|
594
|
-
*/
|
595
|
-
ColumnStackPlugin.prototype._getColumnCount = function() {
|
596
|
-
var host = this._host || this._hosts[0];
|
597
|
-
return host ? host.getColumnCount() : 0;
|
598
|
-
};
|
599
|
-
/** @private
|
600
518
|
* @return {boolean}
|
601
519
|
*/
|
602
520
|
ColumnStackPlugin.prototype._isIconAvailable = function() {
|
@@ -681,7 +599,7 @@ ColumnStackPlugin.prototype._updateUI = function() {
|
|
681
599
|
}
|
682
600
|
|
683
601
|
this._updating = true;
|
684
|
-
var colCount = this.
|
602
|
+
var colCount = this.getColumnCount();
|
685
603
|
var gridCount = this._hosts.length;
|
686
604
|
var stackOpt, spreading;
|
687
605
|
for(var c = 0; c < colCount; ++c) {
|
@@ -957,7 +875,7 @@ ColumnStackPlugin.prototype.isColumnActive = function(colIndex) {
|
|
957
875
|
};
|
958
876
|
|
959
877
|
/** @public
|
960
|
-
* @param {number|string} colRef Column
|
878
|
+
* @param {number|string} colRef Column Id, index or field
|
961
879
|
* @return {string}
|
962
880
|
*/
|
963
881
|
ColumnStackPlugin.prototype.getStackId = function(colRef) {
|
@@ -971,16 +889,12 @@ ColumnStackPlugin.prototype.getStackId = function(colRef) {
|
|
971
889
|
return "";
|
972
890
|
};
|
973
891
|
/** @public
|
974
|
-
* @param {Array.<number|string>=} colRefs
|
892
|
+
* @param {Array.<number|string>=} colRefs Column Ids, indices, or fields. If not specified, selected columns will be used.
|
975
893
|
* @param {string=} stackId Must be unique
|
976
894
|
* @param {ColumnStackPlugin~StackConfiguration=} options
|
977
895
|
* @return {boolean} Return true if there is any change.
|
978
896
|
*/
|
979
897
|
ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options) {
|
980
|
-
if(!options) {
|
981
|
-
options = {};
|
982
|
-
}
|
983
|
-
|
984
898
|
var updateRequired = false;
|
985
899
|
var sid = stackId;
|
986
900
|
if(sid) {
|
@@ -1004,10 +918,14 @@ ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options) {
|
|
1004
918
|
return updateRequired; // Only two or more columns can be stacked
|
1005
919
|
}
|
1006
920
|
|
921
|
+
if(!options) {
|
922
|
+
options = {};
|
923
|
+
}
|
1007
924
|
// Clone user data
|
1008
925
|
var isSpreading = options.spreading === true;
|
1009
926
|
var isCollapsed = options.collapsed !== false;
|
1010
927
|
var activeColumn = options.activeColumn || ""; // field or id
|
928
|
+
// WARNING: fields property in user option is ignored
|
1011
929
|
var stack = {};
|
1012
930
|
stack.id = sid;
|
1013
931
|
stack.name = options.name || "";
|
@@ -1015,7 +933,7 @@ ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options) {
|
|
1015
933
|
stack.collapsed = isCollapsed;
|
1016
934
|
stack.activeColumn = activeColumn; // field or id
|
1017
935
|
|
1018
|
-
// If grid is not
|
936
|
+
// If grid is not initialized, add setting to pending stacks
|
1019
937
|
if(!this._initializedGrid) {
|
1020
938
|
var pendingStacks = this._pendingStacks;
|
1021
939
|
if(!pendingStacks) {
|
@@ -1026,17 +944,7 @@ ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options) {
|
|
1026
944
|
return false;
|
1027
945
|
}
|
1028
946
|
|
1029
|
-
var children = colRefs.map(this._toIdOrField);
|
1030
947
|
var colIndices = this.getColumnIndices(colRefs); // WARNING: Invalid columns are filtered out
|
1031
|
-
var validCount = colIndices.length;
|
1032
|
-
|
1033
|
-
// Save stack fields for autoStacking
|
1034
|
-
if(this._autoStacking){
|
1035
|
-
if(!this._idToFields) {
|
1036
|
-
this._idToFields = {};
|
1037
|
-
}
|
1038
|
-
this._idToFields[sid] = children;
|
1039
|
-
}
|
1040
948
|
|
1041
949
|
// Prevent columns already in a stack from moving out to another stack
|
1042
950
|
if(!this.isColumnStackable(colIndices)) {
|
@@ -1046,17 +954,14 @@ ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options) {
|
|
1046
954
|
return updateRequired;
|
1047
955
|
}
|
1048
956
|
|
1049
|
-
//
|
1050
|
-
|
957
|
+
// WARNING: Invalid columns are filtered out
|
958
|
+
var children = colIndices.map(this._toColumnId); // All fields and indices from colRefs will be converted to column Ids
|
959
|
+
stack.children = children; // Note: children property now contains only valid column ids
|
960
|
+
|
1051
961
|
var activeIndex = -1;
|
1052
962
|
if(activeColumn && typeof activeColumn === "string") {
|
1053
963
|
activeIndex = this.getColumnIndex(activeColumn);
|
1054
|
-
|
1055
|
-
var field = this._getField(activeIndex);
|
1056
|
-
if(field === activeColumn) {
|
1057
|
-
stack.activeColumn = activeColumn = this.getColumnId(activeIndex);
|
1058
|
-
}
|
1059
|
-
}
|
964
|
+
stack.activeColumn = activeColumn = this.getColumnId(activeIndex); // Convert field or invalid column id to a valid id
|
1060
965
|
} else if(typeof activeColumn === "number"){
|
1061
966
|
activeIndex = activeColumn;
|
1062
967
|
}
|
@@ -1072,6 +977,7 @@ ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options) {
|
|
1072
977
|
this.reorderColumns(colIndices, colIndices[0]);
|
1073
978
|
|
1074
979
|
// Update column selection
|
980
|
+
var validCount = colIndices.length;
|
1075
981
|
if(!isSpreading) {
|
1076
982
|
var csp = this._getPlugin("ColumnSelectionPlugin");
|
1077
983
|
if(csp && csp.isEnabled()){
|
@@ -1160,11 +1066,8 @@ ColumnStackPlugin.prototype._freezeColumn = function(frozenColIndex, numRightCol
|
|
1160
1066
|
|
1161
1067
|
/** @public
|
1162
1068
|
* @description Replace all of the stacking in the Grid with a new one.
|
1163
|
-
*
|
1164
|
-
*
|
1165
|
-
* if there are at least two visible columns that match to the retained fields.
|
1166
|
-
* @param {Array.<number|string>=} colRefs Field names or column indices
|
1167
|
-
* @param {number|string=} activeColRef Field names or column index of active column
|
1069
|
+
* @param {Array.<number|string>=} colRefs Column Ids, indices, or fields.
|
1070
|
+
* @param {(number|string)=} activeColRef Column Id, index, or field.
|
1168
1071
|
* @return {boolean} If the stack has been updated, return true.
|
1169
1072
|
*/
|
1170
1073
|
ColumnStackPlugin.prototype.setStack = function(colRefs, activeColRef) {
|
@@ -1180,35 +1083,88 @@ ColumnStackPlugin.prototype.setStack = function(colRefs, activeColRef) {
|
|
1180
1083
|
return true;
|
1181
1084
|
};
|
1182
1085
|
/** @public
|
1183
|
-
* @
|
1184
|
-
* @
|
1086
|
+
* @description Remove all existing stacks and apply the given stack definitions to the Grid
|
1087
|
+
* @param {Array.<ColumnStackPlugin~StackDefinition>} stacks Array of stack definition objects
|
1185
1088
|
*/
|
1186
|
-
ColumnStackPlugin.prototype.
|
1187
|
-
|
1188
|
-
|
1089
|
+
ColumnStackPlugin.prototype.setStacks = function(stacks) {
|
1090
|
+
this.removeAllStacks();
|
1091
|
+
|
1092
|
+
var stackCount = stacks ? stacks.length : 0;
|
1093
|
+
for(var i = 0; i < stackCount; ++i) {
|
1094
|
+
var stack = stacks[i];
|
1095
|
+
if(stack) {
|
1096
|
+
if(stack.children) {
|
1097
|
+
this.stackColumns(stack.children, stack.id, stack);
|
1098
|
+
}
|
1099
|
+
}
|
1189
1100
|
}
|
1101
|
+
};
|
1102
|
+
/** @public
|
1103
|
+
* @description Get stack defintion objects like those returned from getConfigObject
|
1104
|
+
* @return {!Array.<ColumnStackPlugin~StackDefinition>} Array of stack definition objects
|
1105
|
+
*/
|
1106
|
+
ColumnStackPlugin.prototype.getStacks = function() {
|
1107
|
+
var stacks = this._groupDefs.getGroupMap();
|
1108
|
+
var stackOptions = [];
|
1190
1109
|
|
1191
|
-
var
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1110
|
+
for (var stackKey in stacks) {
|
1111
|
+
var stackOption = stacks[stackKey];
|
1112
|
+
var stackId = stackOption.id;
|
1113
|
+
|
1114
|
+
var stackConfigObj = {
|
1115
|
+
id: stackId
|
1116
|
+
};
|
1117
|
+
var name = stackOption.name;
|
1118
|
+
var collapsed = stackOption.collapsed;
|
1119
|
+
var spreading = stackOption.spreading;
|
1120
|
+
|
1121
|
+
if (name) {
|
1122
|
+
stackConfigObj.name = name;
|
1123
|
+
}
|
1124
|
+
if (collapsed !== true) {
|
1125
|
+
stackConfigObj.collapsed = collapsed;
|
1126
|
+
}
|
1127
|
+
if (spreading !== false) {
|
1128
|
+
stackConfigObj.spreading = spreading;
|
1129
|
+
}
|
1195
1130
|
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
var
|
1200
|
-
|
1201
|
-
|
1131
|
+
if (this._usingField) {
|
1132
|
+
var colIndices = this.getStackMemberIndices(stackId);
|
1133
|
+
var memberCount = colIndices.length;
|
1134
|
+
var fields = new Array(memberCount);
|
1135
|
+
for(var i = 0; i < memberCount; ++i) {
|
1136
|
+
fields[i] = this.getColumnField(colIndices[i]);
|
1137
|
+
}
|
1138
|
+
stackConfigObj.fields = fields;
|
1139
|
+
stackConfigObj.activeColumn = this.getActiveColumnField(stackId);
|
1140
|
+
} else {
|
1141
|
+
stackConfigObj.children = this.getStackMemberIds(stackId).slice();
|
1142
|
+
if(stackOption.activeColumn) {
|
1143
|
+
stackConfigObj.activeColumn = stackOption.activeColumn;
|
1202
1144
|
}
|
1203
1145
|
}
|
1146
|
+
stackOptions.push(stackConfigObj);
|
1147
|
+
}
|
1148
|
+
return stackOptions;
|
1149
|
+
};
|
1150
|
+
|
1151
|
+
/** @public
|
1152
|
+
* @param {Array.<number>=} colIndices Selected columns will be used, if it is not given
|
1153
|
+
* @return {boolean}
|
1154
|
+
*/
|
1155
|
+
ColumnStackPlugin.prototype.unstackColumns = function(colIndices) {
|
1156
|
+
if(!colIndices) {
|
1157
|
+
colIndices = this._getSelectedColumns();
|
1204
1158
|
}
|
1205
1159
|
|
1206
1160
|
var dirty = false;
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1161
|
+
var len = colIndices.length;
|
1162
|
+
for(var i = 0; i < len; ++i) {
|
1163
|
+
var colIndex = colIndices[i];
|
1164
|
+
var stackOpt = this._getColumnStackOptions(colIndex);
|
1165
|
+
if(stackOpt) {
|
1166
|
+
dirty = true;
|
1167
|
+
this._removeStack(stackOpt.id);
|
1212
1168
|
}
|
1213
1169
|
}
|
1214
1170
|
if(dirty) {
|
@@ -1249,11 +1205,6 @@ ColumnStackPlugin.prototype._removeStack = function(stackId) {
|
|
1249
1205
|
* @return {boolean} Returns true if there is any change
|
1250
1206
|
*/
|
1251
1207
|
ColumnStackPlugin.prototype.removeStack = function(stackId) {
|
1252
|
-
if(this._idToFields) {
|
1253
|
-
if(this._idToFields[stackId]) {
|
1254
|
-
delete this._idToFields[stackId];
|
1255
|
-
}
|
1256
|
-
}
|
1257
1208
|
if(this._removeStack(stackId)) {
|
1258
1209
|
this._updateUI();
|
1259
1210
|
return true;
|
@@ -1267,11 +1218,10 @@ ColumnStackPlugin.prototype.removeStack = function(stackId) {
|
|
1267
1218
|
ColumnStackPlugin.prototype.removeAllStacks = function(enableUpdateUI) {
|
1268
1219
|
var groupIds = this._groupDefs.getGroupIds();
|
1269
1220
|
var groupCount = groupIds.length;
|
1270
|
-
for(var i = 0; i < groupCount; ++i) {
|
1271
|
-
this._removeStack(groupIds[i]);
|
1272
|
-
}
|
1273
1221
|
if(groupCount) {
|
1274
|
-
|
1222
|
+
for(var i = 0; i < groupCount; ++i) {
|
1223
|
+
this._removeStack(groupIds[i]);
|
1224
|
+
}
|
1275
1225
|
this._groupDefs.removeAllGroups(); // TODO: May not necessary
|
1276
1226
|
|
1277
1227
|
if(enableUpdateUI !== false) {
|
@@ -1297,16 +1247,11 @@ ColumnStackPlugin.prototype.setActiveColumn = function(activeColumn) {
|
|
1297
1247
|
|
1298
1248
|
var colId = this.getColumnId(colIndex);
|
1299
1249
|
var stack = this._groupDefs.getParentGroup(colId);
|
1300
|
-
var field = "";
|
1301
|
-
if(!stack) {
|
1302
|
-
field = this._getField(colIndex);
|
1303
|
-
stack = this._groupDefs.getParentGroup(field);
|
1304
|
-
}
|
1305
1250
|
if(!stack) {
|
1306
1251
|
return false;
|
1307
1252
|
}
|
1308
1253
|
var chdr = stack.children;
|
1309
|
-
var memberIndex =
|
1254
|
+
var memberIndex = chdr.indexOf(colId);
|
1310
1255
|
if(memberIndex < 0) {
|
1311
1256
|
return false;
|
1312
1257
|
}
|
@@ -1387,21 +1332,11 @@ ColumnStackPlugin.prototype._onColumnRemoved = function (e) {
|
|
1387
1332
|
return;
|
1388
1333
|
}
|
1389
1334
|
|
1390
|
-
var colRef = "";
|
1391
1335
|
var colId = e.colId;
|
1392
1336
|
var stackOpt = this._groupDefs.getParentGroup(colId);
|
1393
1337
|
|
1394
|
-
if(stackOpt) {
|
1395
|
-
|
1396
|
-
} else {
|
1397
|
-
var colData = /** @type{Object} */(e.columnData);
|
1398
|
-
var field = colData ? colData.field : "";
|
1399
|
-
stackOpt = this._groupDefs.getParentGroup(field);
|
1400
|
-
if(stackOpt) {
|
1401
|
-
colRef = field;
|
1402
|
-
} else {
|
1403
|
-
return;
|
1404
|
-
}
|
1338
|
+
if(!stackOpt) {
|
1339
|
+
return;
|
1405
1340
|
}
|
1406
1341
|
// update members
|
1407
1342
|
var children = stackOpt.children;
|
@@ -1409,7 +1344,7 @@ ColumnStackPlugin.prototype._onColumnRemoved = function (e) {
|
|
1409
1344
|
this._removeStack(stackOpt.id);
|
1410
1345
|
this._updateUI();
|
1411
1346
|
} else {
|
1412
|
-
this._groupDefs.removeGroupChild(stackOpt.id,
|
1347
|
+
this._groupDefs.removeGroupChild(stackOpt.id, colId);
|
1413
1348
|
this._updateActiveColumn(stackOpt); // This may trigger _updateUI
|
1414
1349
|
}
|
1415
1350
|
};
|
@@ -1418,21 +1353,17 @@ ColumnStackPlugin.prototype._onColumnRemoved = function (e) {
|
|
1418
1353
|
*/
|
1419
1354
|
ColumnStackPlugin.prototype._onColumnMoved = function (e) {
|
1420
1355
|
if(this._inReordering || this._inResetting) {
|
1356
|
+
if(this._inReordering) {
|
1357
|
+
this._inReordering = 2; // Mark dirty
|
1358
|
+
}
|
1421
1359
|
return; // during the reordering or resetting, there is no need to recalculate stacks
|
1422
1360
|
}
|
1423
1361
|
|
1424
1362
|
var toIndex = e.toColIndex;
|
1425
|
-
var colRef = "";
|
1426
1363
|
var colId = this.getColumnId(toIndex);
|
1427
1364
|
var stackOpt = this._groupDefs.getParentGroup(colId);
|
1428
|
-
if(stackOpt) {
|
1429
|
-
|
1430
|
-
} else {
|
1431
|
-
var field = this._getField(toIndex);
|
1432
|
-
stackOpt = this._groupDefs.getParentGroup(field);
|
1433
|
-
if(stackOpt) {
|
1434
|
-
colRef = field;
|
1435
|
-
}
|
1365
|
+
if(!stackOpt) {
|
1366
|
+
return;
|
1436
1367
|
}
|
1437
1368
|
|
1438
1369
|
var leftStackOpt = this._getColumnStackOptions(toIndex - 1);
|
@@ -1449,7 +1380,7 @@ ColumnStackPlugin.prototype._onColumnMoved = function (e) {
|
|
1449
1380
|
if(stackOpt.children.length <= 2) {
|
1450
1381
|
this._removeStack(stackOpt.id);
|
1451
1382
|
} else {
|
1452
|
-
this._removeRefFromStack(stackOpt,
|
1383
|
+
this._removeRefFromStack(stackOpt, colId, toIndex);
|
1453
1384
|
}
|
1454
1385
|
}
|
1455
1386
|
dirty = true;
|
@@ -1471,18 +1402,15 @@ ColumnStackPlugin.prototype._onColumnMoved = function (e) {
|
|
1471
1402
|
* @param {Object} e
|
1472
1403
|
*/
|
1473
1404
|
ColumnStackPlugin.prototype._onColumnAdded = function (e) {
|
1474
|
-
|
1405
|
+
if(this._inResetting) {
|
1406
|
+
return;
|
1407
|
+
}
|
1475
1408
|
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
var stackOpt = this._isWithinStack(colIndex);
|
1482
|
-
if(stackOpt) {
|
1483
|
-
if(this._addRefToStack(stackOpt, colIndex)) {
|
1484
|
-
this._updateUI();
|
1485
|
-
}
|
1409
|
+
var colIndex = e.colIndex;
|
1410
|
+
var stackOpt = this._isWithinStack(colIndex);
|
1411
|
+
if(stackOpt) {
|
1412
|
+
if(this._addRefToStack(stackOpt, colIndex)) {
|
1413
|
+
this._updateUI();
|
1486
1414
|
}
|
1487
1415
|
}
|
1488
1416
|
};
|
@@ -1493,26 +1421,38 @@ ColumnStackPlugin.prototype._onBeforeBatchOperation = function (e) {
|
|
1493
1421
|
if(e.batchType === "reset") {
|
1494
1422
|
this._inResetting = true;
|
1495
1423
|
} else if(e.batchType === "move") {
|
1496
|
-
this._inReordering =
|
1424
|
+
this._inReordering = 1;
|
1497
1425
|
}
|
1498
1426
|
};
|
1499
1427
|
/** @private
|
1500
1428
|
* @param {Object} e
|
1501
1429
|
*/
|
1502
1430
|
ColumnStackPlugin.prototype._onAfterBatchOperation = function (e) {
|
1431
|
+
var groups, groupCount, i, group;
|
1503
1432
|
if(e.batchType === "reset") {
|
1504
1433
|
this._inResetting = false;
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1434
|
+
|
1435
|
+
groups = this._groupDefs.getGroups();
|
1436
|
+
groupCount = groups.length;
|
1437
|
+
for(i = 0; i < groupCount; ++i) {
|
1438
|
+
this._repositionMembers(groups[i], true); // validate the group
|
1439
|
+
}
|
1440
|
+
groups = this._groupDefs.getGroups();
|
1441
|
+
groupCount = groups.length;
|
1442
|
+
for(i = 0; i < groupCount; ++i) {
|
1443
|
+
group = groups[i];
|
1511
1444
|
this._updateActiveColumn(group);
|
1512
1445
|
this._hideStackedColumns(group);
|
1513
1446
|
}
|
1514
1447
|
} else if(e.batchType === "move") {
|
1515
|
-
this._inReordering
|
1448
|
+
if(this._inReordering === 2) {
|
1449
|
+
groups = this._groupDefs.getGroups();
|
1450
|
+
groupCount = groups.length;
|
1451
|
+
for(i = 0; i < groupCount; ++i) {
|
1452
|
+
this._repositionMembers(groups[i]);
|
1453
|
+
}
|
1454
|
+
}
|
1455
|
+
this._inReordering = 0;
|
1516
1456
|
}
|
1517
1457
|
};
|
1518
1458
|
/** @private
|
@@ -1547,12 +1487,12 @@ ColumnStackPlugin.prototype._isWithinStack = function (colIndex) {
|
|
1547
1487
|
* @return {boolean}
|
1548
1488
|
*/
|
1549
1489
|
ColumnStackPlugin.prototype._addRefToStack = function (stackOption, colIndex) {
|
1550
|
-
var colId = this.
|
1490
|
+
var colId = this._toColumnId(colIndex);
|
1551
1491
|
|
1552
1492
|
this._hideStackedColumns(stackOption, colIndex);
|
1553
1493
|
|
1554
1494
|
// Find a position to be placed in the stack
|
1555
|
-
var rightColRef = this.
|
1495
|
+
var rightColRef = this._toColumnId(colIndex + 1);
|
1556
1496
|
var children = stackOption.children;
|
1557
1497
|
var pos = children.indexOf(rightColRef); // WARNING This does not work for field
|
1558
1498
|
return this._groupDefs.addGroupChild(stackOption.id, colId, pos);
|
@@ -1582,23 +1522,50 @@ ColumnStackPlugin.prototype._removeRefFromStack = function (stackOption, colRef,
|
|
1582
1522
|
|
1583
1523
|
/** @private
|
1584
1524
|
* @param {Object} stackOption
|
1525
|
+
* @param {boolean=} validate Remove invalid members and stack
|
1585
1526
|
*/
|
1586
|
-
ColumnStackPlugin.prototype._repositionMembers = function (stackOption) {
|
1527
|
+
ColumnStackPlugin.prototype._repositionMembers = function (stackOption, validate) {
|
1587
1528
|
var children = stackOption.children;
|
1588
1529
|
var refCount = children ? children.length : 0;
|
1589
|
-
if(!refCount) {
|
1590
|
-
return;
|
1591
|
-
}
|
1592
1530
|
|
1593
|
-
var
|
1594
|
-
var
|
1595
|
-
|
1531
|
+
var indexMap = {};
|
1532
|
+
var prevIndex = -1;
|
1533
|
+
var dirty = false;
|
1534
|
+
var hasInvalid = false;
|
1535
|
+
for(var i = 0; i < refCount; i++) {
|
1596
1536
|
var colRef = children[i];
|
1597
|
-
|
1537
|
+
var colIndex = this.getColumnIndex(colRef);
|
1538
|
+
indexMap[colRef] = colIndex;
|
1539
|
+
if(colIndex >= 0) {
|
1540
|
+
if(colIndex < prevIndex) {
|
1541
|
+
dirty = true;
|
1542
|
+
}
|
1543
|
+
} else { // Found invalid member
|
1544
|
+
hasInvalid = true;
|
1545
|
+
}
|
1546
|
+
prevIndex = colIndex;
|
1547
|
+
}
|
1548
|
+
if(validate && hasInvalid) {
|
1549
|
+
children = children.filter(_byValidIndex.bind(null, indexMap));
|
1550
|
+
// WARNING: this._groupDefs._childToParent may be out of sync after children are filtered
|
1551
|
+
// TODO: Create a new API to rebuild childToParent map
|
1552
|
+
this._groupDefs.removeAllChildren(stackOption.id);
|
1553
|
+
stackOption.children = children;
|
1554
|
+
this._groupDefs.setGroup(stackOption.id, stackOption);
|
1555
|
+
|
1556
|
+
refCount = children.length;
|
1557
|
+
}
|
1558
|
+
|
1559
|
+
if(refCount < 2) {
|
1560
|
+
if(validate) {
|
1561
|
+
this._removeStack(stackOption.id);
|
1562
|
+
this._updateUI();
|
1563
|
+
}
|
1564
|
+
return;
|
1598
1565
|
}
|
1599
|
-
|
1600
|
-
|
1601
|
-
children
|
1566
|
+
|
1567
|
+
if(dirty || hasInvalid) {
|
1568
|
+
children.sort(_indexSorter.bind(null, indexMap));
|
1602
1569
|
}
|
1603
1570
|
};
|
1604
1571
|
/** @private
|
@@ -1634,7 +1601,7 @@ ColumnStackPlugin.prototype._onStackButtonClicked = function(e) {
|
|
1634
1601
|
value: i,
|
1635
1602
|
selected: i === activeIndex,
|
1636
1603
|
label: this.getColumnName(colIndices[i]),
|
1637
|
-
field: this.
|
1604
|
+
field: this.getColumnField(colIndices[i])
|
1638
1605
|
};
|
1639
1606
|
}
|
1640
1607
|
pos["menuData"] = menuData;
|
@@ -1648,40 +1615,13 @@ ColumnStackPlugin.prototype._onStackButtonClicked = function(e) {
|
|
1648
1615
|
this._dispatch("clicked", pos);
|
1649
1616
|
};
|
1650
1617
|
|
1651
|
-
/** Remove existing stacks and apply persist stack
|
1652
|
-
* @private
|
1653
|
-
*/
|
1654
|
-
ColumnStackPlugin.prototype._requestStackingByFields = function() {
|
1655
|
-
if(this._stackConflator.conflate()) {
|
1656
|
-
return;
|
1657
|
-
}
|
1658
|
-
|
1659
|
-
var columnStack = this._idToFields;
|
1660
|
-
if(columnStack){
|
1661
|
-
this.removeAllStacks(false);
|
1662
|
-
for(var sid in columnStack){
|
1663
|
-
var fields = columnStack[sid];
|
1664
|
-
var colIndices = this.getColumnIndices(fields);
|
1665
|
-
if (colIndices.length > 1) {
|
1666
|
-
this.stackColumns(fields, sid);
|
1667
|
-
}
|
1668
|
-
}
|
1669
|
-
}
|
1670
|
-
};
|
1671
|
-
|
1672
1618
|
/** @public
|
1673
1619
|
* @description Get member column indices in a stack
|
1674
1620
|
* @param {string} stackId
|
1675
1621
|
* @return {!Array.<number>} Member column indices
|
1676
1622
|
*/
|
1677
1623
|
ColumnStackPlugin.prototype.getStackMemberIndices = function(stackId) {
|
1678
|
-
|
1679
|
-
var stack = this._groupDefs.getGroup(stackId);
|
1680
|
-
if(stack){
|
1681
|
-
return this.getColumnIndices(stack.children);
|
1682
|
-
}
|
1683
|
-
}
|
1684
|
-
return [];
|
1624
|
+
return this.getColumnIndices(this.getStackMemberIds(stackId));
|
1685
1625
|
};
|
1686
1626
|
|
1687
1627
|
/** @public
|
@@ -1689,13 +1629,14 @@ ColumnStackPlugin.prototype.getStackMemberIndices = function(stackId) {
|
|
1689
1629
|
* @param {string} stackId
|
1690
1630
|
* @return {!Array.<string>} Member column ids
|
1691
1631
|
*/
|
1692
|
-
ColumnStackPlugin.prototype.getStackMemberIds = function(stackId) {
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1632
|
+
ColumnStackPlugin.prototype.getStackMemberIds = function(stackId) { // WARNING: This does not filter out invalid members
|
1633
|
+
if(stackId) {
|
1634
|
+
var stack = this._groupDefs.getGroup(stackId);
|
1635
|
+
if(stack){
|
1636
|
+
return stack.children;
|
1637
|
+
}
|
1696
1638
|
}
|
1697
|
-
|
1698
|
-
return colIndices;
|
1639
|
+
return [];
|
1699
1640
|
};
|
1700
1641
|
|
1701
1642
|
/** @public
|
@@ -1740,13 +1681,25 @@ ColumnStackPlugin.prototype.getColumnIndicesByColumnIds = function(colIds) {
|
|
1740
1681
|
* @return {!Array.<string>} Column indices
|
1741
1682
|
*/
|
1742
1683
|
ColumnStackPlugin.prototype.getColumnIdsByFields = function(fields) {
|
1743
|
-
if(!
|
1744
|
-
|
1684
|
+
if(!fields) {
|
1685
|
+
return [];
|
1686
|
+
}
|
1687
|
+
var ary = Array.isArray(fields) ? fields : [fields];
|
1688
|
+
var count = fields.length;
|
1689
|
+
var outAry = new Array(count);
|
1690
|
+
for(var i = 0; i < count; ++i) {
|
1691
|
+
var ref = ary[i];
|
1692
|
+
var colIndex = -1;
|
1693
|
+
if(typeof ref === "number") {
|
1694
|
+
colIndex = ref;
|
1695
|
+
} else if(ref) {
|
1696
|
+
if(typeof ref === "string") {
|
1697
|
+
colIndex = this.getColumnIndex(ref);
|
1698
|
+
}
|
1699
|
+
}
|
1700
|
+
outAry[i] = (colIndex >= 0) ? this.getColumnId(colIndex) : "";
|
1745
1701
|
}
|
1746
|
-
|
1747
|
-
var colIndices = this.getColumnIndices(fields);
|
1748
|
-
|
1749
|
-
return this.getColumnIdsByIndex(colIndices);
|
1702
|
+
return outAry;
|
1750
1703
|
};
|
1751
1704
|
|
1752
1705
|
/** @public
|
@@ -1755,7 +1708,7 @@ ColumnStackPlugin.prototype.getColumnIdsByFields = function(fields) {
|
|
1755
1708
|
* @param {string} stackId
|
1756
1709
|
*/
|
1757
1710
|
ColumnStackPlugin.prototype.addColumnToStack = function(colRef, stackId) {
|
1758
|
-
var colId = this.
|
1711
|
+
var colId = this._toColumnId(colRef);
|
1759
1712
|
|
1760
1713
|
var stack = this._groupDefs.getGroup(stackId);
|
1761
1714
|
var isColumnStackable = !this._groupDefs.getParentGroup(colId);
|
@@ -1805,15 +1758,6 @@ ColumnStackPlugin.prototype.removeColumnFromStack = function(colRef) {
|
|
1805
1758
|
|
1806
1759
|
var colId = this.getColumnId(colIndex);
|
1807
1760
|
var stack = this._groupDefs.getParentGroup(colId);
|
1808
|
-
if(stack) {
|
1809
|
-
colRef = colId;
|
1810
|
-
} else {
|
1811
|
-
var field = this._getField(colIndex);
|
1812
|
-
stack = this._groupDefs.getParentGroup(field);
|
1813
|
-
if(stack) {
|
1814
|
-
colRef = field;
|
1815
|
-
}
|
1816
|
-
}
|
1817
1761
|
|
1818
1762
|
if(!stack) {
|
1819
1763
|
return;
|
@@ -1823,7 +1767,7 @@ ColumnStackPlugin.prototype.removeColumnFromStack = function(colRef) {
|
|
1823
1767
|
var memberCount = children.length;
|
1824
1768
|
if(memberCount <= 2) {
|
1825
1769
|
if(memberCount === 2) {
|
1826
|
-
if(
|
1770
|
+
if(colId === children[0]) { // If the first column is removed from the stack, move it to the end of stack
|
1827
1771
|
// This assumes that the column order is already in correct position
|
1828
1772
|
this.moveColumnById(colIndex, this.getColumnIndex(children[1]) + 1);
|
1829
1773
|
}
|
@@ -1842,7 +1786,7 @@ ColumnStackPlugin.prototype.removeColumnFromStack = function(colRef) {
|
|
1842
1786
|
|
1843
1787
|
/** @public
|
1844
1788
|
* @description Reorder columns in a stack
|
1845
|
-
* @param {Array.<number|string>} colRefs
|
1789
|
+
* @param {Array.<number|string>} colRefs Column Ids, indices, or fields
|
1846
1790
|
* @param {string} stackId
|
1847
1791
|
*/
|
1848
1792
|
ColumnStackPlugin.prototype.reorderStackColumns = function(colRefs, stackId) {
|
@@ -1850,47 +1794,24 @@ ColumnStackPlugin.prototype.reorderStackColumns = function(colRefs, stackId) {
|
|
1850
1794
|
if(!stack) {
|
1851
1795
|
return;
|
1852
1796
|
}
|
1853
|
-
|
1854
|
-
|
1855
|
-
var stackMemberCount = stackMemberIndices.length;
|
1856
|
-
var len = colRefs.length;
|
1857
|
-
if(len) {
|
1858
|
-
if(typeof colRefs[0] === "string") {
|
1859
|
-
colRefs = this.getColumnIndices(colRefs);
|
1860
|
-
}
|
1861
|
-
}
|
1862
|
-
|
1863
|
-
var newStackMembers = [];
|
1864
|
-
var i, colIndex;
|
1865
|
-
for(i = 0; i < len; i++ ){
|
1866
|
-
colIndex = colRefs[i];
|
1867
|
-
if(stackMemberIndices.indexOf(colIndex) >= 0){
|
1868
|
-
newStackMembers.push(colIndex);
|
1869
|
-
}
|
1797
|
+
if(!colRefs || !colRefs.length) {
|
1798
|
+
return; // Nothing to be reordered
|
1870
1799
|
}
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
if(newStackMembers.indexOf(colIndex) < 0){
|
1875
|
-
newStackMembers.push(colIndex);
|
1876
|
-
if(newStackMembers.length === stackMemberCount){
|
1877
|
-
break;
|
1878
|
-
}
|
1879
|
-
}
|
1880
|
-
}
|
1800
|
+
var colIndices = this.getColumnIndices(colRefs); // Slow
|
1801
|
+
if(!colIndices.length) {
|
1802
|
+
return; // Given input has no valid column
|
1881
1803
|
}
|
1882
1804
|
|
1883
|
-
var
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
newStackMembers[i] = this._getField(newStackMembers[i]);
|
1805
|
+
var curMemberIndices = this.getStackMemberIndices(stackId); // Slow
|
1806
|
+
var memberCount = curMemberIndices.length;
|
1807
|
+
var indexMap = {};
|
1808
|
+
for(var i = 0; i < memberCount; ++i) {
|
1809
|
+
var colIndex = curMemberIndices[i];
|
1810
|
+
indexMap[colIndex] = colIndices.indexOf(colIndex);
|
1890
1811
|
}
|
1891
1812
|
|
1892
|
-
|
1893
|
-
this.
|
1813
|
+
curMemberIndices.sort(_indexSorter.bind(null, indexMap));
|
1814
|
+
this.reorderColumns(curMemberIndices, curMemberIndices[0]);
|
1894
1815
|
};
|
1895
1816
|
|
1896
1817
|
/** @public
|
@@ -1911,13 +1832,25 @@ ColumnStackPlugin.prototype.getStackName = function(stackId) {
|
|
1911
1832
|
return this._groupDefs.getGroupName(stackId);
|
1912
1833
|
};
|
1913
1834
|
|
1835
|
+
/** @public
|
1836
|
+
* @description Get active column id of specific stack
|
1837
|
+
* @param {string} stackId
|
1838
|
+
* @return {string} active column id
|
1839
|
+
*/
|
1840
|
+
ColumnStackPlugin.prototype.getActiveColumnId = function(stackId) {
|
1841
|
+
var stack = this._groupDefs.getGroup(stackId);
|
1842
|
+
if(stack){
|
1843
|
+
return stack.activeColumn || "";
|
1844
|
+
}
|
1845
|
+
return "";
|
1846
|
+
};
|
1914
1847
|
/** @public
|
1915
1848
|
* @description Get active column field of specific stack
|
1916
1849
|
* @param {string} stackId
|
1917
1850
|
* @return {string} active column field
|
1918
1851
|
*/
|
1919
1852
|
ColumnStackPlugin.prototype.getActiveColumnField = function(stackId) {
|
1920
|
-
return this.
|
1853
|
+
return this.getColumnField(this.getActiveColumnIndex(stackId));
|
1921
1854
|
};
|
1922
1855
|
|
1923
1856
|
/** @public
|
@@ -1932,11 +1865,10 @@ ColumnStackPlugin.prototype.getActiveColumnIndex = function(stackId) {
|
|
1932
1865
|
}
|
1933
1866
|
return -1;
|
1934
1867
|
};
|
1935
|
-
//getActiveColumnIndex
|
1936
1868
|
|
1937
1869
|
/** @public
|
1938
1870
|
* @param {string} stackId
|
1939
|
-
* @param {number|string} colRef Column
|
1871
|
+
* @param {number|string} colRef Column Id, index or field
|
1940
1872
|
*/
|
1941
1873
|
ColumnStackPlugin.prototype.addStackChild = function(stackId, colRef) {
|
1942
1874
|
this.addColumnToStack(colRef, stackId);
|
@@ -1944,7 +1876,7 @@ ColumnStackPlugin.prototype.addStackChild = function(stackId, colRef) {
|
|
1944
1876
|
/**
|
1945
1877
|
* @public
|
1946
1878
|
* @param {string} stackId
|
1947
|
-
* @param {number|string} colRef Column
|
1879
|
+
* @param {number|string} colRef Column Id, index or field
|
1948
1880
|
*/
|
1949
1881
|
ColumnStackPlugin.prototype.removeStackChild = function(stackId, colRef) {
|
1950
1882
|
if(stackId === this.getStackId(colRef)) {
|
@@ -1953,7 +1885,7 @@ ColumnStackPlugin.prototype.removeStackChild = function(stackId, colRef) {
|
|
1953
1885
|
};
|
1954
1886
|
/** @public
|
1955
1887
|
* @function
|
1956
|
-
* @param {number|string} colRef Column
|
1888
|
+
* @param {number|string} colRef Column Id, index or field
|
1957
1889
|
*/
|
1958
1890
|
ColumnStackPlugin.prototype.unsetParent = ColumnStackPlugin.prototype.removeColumnFromStack;
|
1959
1891
|
|
@@ -1964,13 +1896,7 @@ ColumnStackPlugin.prototype.unsetParent = ColumnStackPlugin.prototype.removeColu
|
|
1964
1896
|
* @return {boolean}
|
1965
1897
|
*/
|
1966
1898
|
ColumnStackPlugin.prototype.reorderColumns = function(colList, destCol) {
|
1967
|
-
|
1968
|
-
this._inReordering = true;
|
1969
|
-
|
1970
|
-
dirty = this._reorderColumns(colList, destCol);
|
1971
|
-
|
1972
|
-
this._inReordering = false;
|
1973
|
-
return dirty;
|
1899
|
+
return this._reorderColumns(colList, destCol);
|
1974
1900
|
};
|
1975
1901
|
/** Move the specified column to position before the destination
|
1976
1902
|
* @public
|
@@ -2070,7 +1996,7 @@ ColumnStackPlugin.prototype.moveStack = function(stackId, destCol) {
|
|
2070
1996
|
if(!stackId){
|
2071
1997
|
return false;
|
2072
1998
|
}
|
2073
|
-
var colList = this.getStackMemberIds(stackId);
|
1999
|
+
var colList = this.getStackMemberIds(stackId);
|
2074
2000
|
var dirty = this.reorderColumns(colList, destCol);
|
2075
2001
|
return dirty;
|
2076
2002
|
};
|
@@ -2093,7 +2019,7 @@ ColumnStackPlugin.prototype.pinStack = function(stackId, side) {
|
|
2093
2019
|
var leftPinnedIndex = host.getFrozenColumnCount() - 1;
|
2094
2020
|
var rightPinnedCount = host.getPinnedRightColumnCount();
|
2095
2021
|
var colCount = this.getColumnCount();
|
2096
|
-
var colList = this.getStackMemberIds(stackId);
|
2022
|
+
var colList = this.getStackMemberIds(stackId);
|
2097
2023
|
var len = colList.length;
|
2098
2024
|
|
2099
2025
|
var dest;
|
@@ -2148,7 +2074,7 @@ ColumnStackPlugin.prototype.unpinStack = function(stackId, dest) {
|
|
2148
2074
|
var rightPinnedCount = host.getPinnedRightColumnCount();
|
2149
2075
|
var colCount = this.getColumnCount();
|
2150
2076
|
var firstRightPinnedIndex = colCount - rightPinnedCount;
|
2151
|
-
var colList = this.getStackMemberIds(stackId);
|
2077
|
+
var colList = this.getStackMemberIds(stackId);
|
2152
2078
|
var len = colList.length;
|
2153
2079
|
|
2154
2080
|
var destId = null;
|