@refinitiv-ui/efx-grid 6.0.16 → 6.0.18
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/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +177 -64
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/ColumnDefinition.js +2 -1
- package/lib/rt-grid/es6/Grid.d.ts +12 -2
- package/lib/rt-grid/es6/Grid.js +152 -54
- package/lib/rt-grid/es6/RowDefinition.js +4 -0
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +4 -4
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +344 -185
- package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +7 -1
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +164 -147
- package/lib/tr-grid-filter-input/es6/FilterInput.d.ts +1 -0
- package/lib/tr-grid-filter-input/es6/FilterInput.js +27 -0
- 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/ColumnGrouping.d.ts +4 -4
- 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 +13 -1
- 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 +5 -5
- package/package.json +1 -1
@@ -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;
|
@@ -11,6 +11,7 @@ import { preventDefault } from "../../tr-grid-util/es6/EventDispatcher.js";
|
|
11
11
|
* @description Available options describing `columnStack` object specified in grid's option
|
12
12
|
* @property {Array.<string>} fields Fields for stacking. The minimum is 2 fields.
|
13
13
|
* @property {Array.<ColumnStackPlugin~StackDefinition>} stacks List of stacking configuration
|
14
|
+
* @property {boolean=} autoStacking=false If enabled, columns will be auto stacked when new inserted column field match in stack
|
14
15
|
*/
|
15
16
|
|
16
17
|
/** @typedef {Object} ColumnStackPlugin~ColumnOptions
|
@@ -31,9 +32,10 @@ import { preventDefault } from "../../tr-grid-util/es6/EventDispatcher.js";
|
|
31
32
|
* @property {string} id Group ID
|
32
33
|
* @property {boolean=} spreading=false If specified true, this group will be running in collapsing mode
|
33
34
|
* @property {boolean=} collapsed=true If disabled, this group will be expanded at the first time
|
34
|
-
* @property {Array.<string>} children Children column ID
|
35
|
+
* @property {Array.<string>} children Children column ID. Used when autoStacking is disabled
|
36
|
+
* @property {Array.<string>} fields Children fiields. Used when autoStacking is enabled
|
35
37
|
* @property {string=} name="" Name defined for specific stack
|
36
|
-
* @property {string=} activeColumn=""
|
38
|
+
* @property {string=} activeColumn="" If enable autoStacking, field of active column in stack. Else, column Id of active column in stack.
|
37
39
|
*/
|
38
40
|
|
39
41
|
/** @typedef {Object} ColumnStackPlugin~StackConfiguration
|
@@ -79,6 +81,10 @@ ColumnStackPlugin.prototype._columnStack = null;
|
|
79
81
|
* @private
|
80
82
|
*/
|
81
83
|
ColumnStackPlugin.prototype._updating = false;
|
84
|
+
/** @type {boolean}
|
85
|
+
* @private
|
86
|
+
*/
|
87
|
+
ColumnStackPlugin.prototype._autoStacking = false;
|
82
88
|
|
83
89
|
|
84
90
|
/** @type {number}
|
@@ -215,8 +221,12 @@ ColumnStackPlugin.prototype.config = function (options) {
|
|
215
221
|
var sid, stacks = {};
|
216
222
|
var columnStack = options.columnStack;
|
217
223
|
if(columnStack != null) {
|
224
|
+
if(columnStack.autoStacking != null) {
|
225
|
+
this._autoStacking = columnStack.autoStacking;
|
226
|
+
}
|
227
|
+
|
218
228
|
if(columnStack.fields && columnStack.fields.length > 1) {
|
219
|
-
this._columnStack =
|
229
|
+
this._columnStack = columnStack.fields;
|
220
230
|
sid = this._generateStackId();
|
221
231
|
stacks[sid] = {
|
222
232
|
colRefs: columnStack.fields,
|
@@ -289,39 +299,64 @@ ColumnStackPlugin.prototype.config = function (options) {
|
|
289
299
|
ColumnStackPlugin.prototype.getConfigObject = function (gridOptions) {
|
290
300
|
var obj = gridOptions || {};
|
291
301
|
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
if (name) {
|
310
|
-
stackConfigObj.name = name;
|
311
|
-
}
|
312
|
-
if (collapsed !== true) {
|
313
|
-
stackConfigObj.collapsed = collapsed;
|
314
|
-
}
|
315
|
-
if (spreading !== false) {
|
316
|
-
stackConfigObj.spreading = spreading;
|
302
|
+
var columnOptions = obj["columns"];
|
303
|
+
|
304
|
+
var stacks = this._stacks;
|
305
|
+
var stackOptions = [];
|
306
|
+
|
307
|
+
for (var stackKey in stacks) {
|
308
|
+
var stackOption = stacks[stackKey];
|
309
|
+
var activeColIndex = this._getColumnIndex(stackOption.activeColumn);
|
310
|
+
|
311
|
+
if(columnOptions && columnOptions.length){
|
312
|
+
var memberIndices = this.getStackMemberIndices(stackOption.stackId);
|
313
|
+
for(var i = 0; i < memberIndices.length; i++){
|
314
|
+
var colIndex = memberIndices[i];
|
315
|
+
var colOption = columnOptions[colIndex];
|
316
|
+
if(colOption){
|
317
|
+
colOption.hidden = colIndex !== activeColIndex;
|
318
|
+
}
|
317
319
|
}
|
318
|
-
stackOptions.push(stackConfigObj);
|
319
320
|
}
|
320
321
|
|
321
|
-
|
322
|
-
|
322
|
+
var stackConfigObj = {
|
323
|
+
id: stackOption.stackId
|
324
|
+
};
|
325
|
+
var name = stackOption.name;
|
326
|
+
var collapsed = stackOption.collapsed;
|
327
|
+
var spreading = stackOption.spreading;
|
328
|
+
|
329
|
+
if (name) {
|
330
|
+
stackConfigObj.name = name;
|
331
|
+
}
|
332
|
+
if (collapsed !== true) {
|
333
|
+
stackConfigObj.collapsed = collapsed;
|
334
|
+
}
|
335
|
+
if (spreading !== false) {
|
336
|
+
stackConfigObj.spreading = spreading;
|
337
|
+
}
|
338
|
+
|
339
|
+
if (this._autoStacking) {
|
340
|
+
var fields = this._columnStack[stackOption.stackId];
|
341
|
+
var activeColumnField = this._getField(activeColIndex);
|
342
|
+
|
343
|
+
stackConfigObj.fields = fields;
|
344
|
+
stackConfigObj.activeColumn = activeColumnField;
|
345
|
+
|
346
|
+
} else {
|
347
|
+
var children = this.getStackMemberIds(stackOption.stackId);
|
348
|
+
var activeColumn = this.getColumnId(activeColIndex);
|
349
|
+
|
350
|
+
stackConfigObj.children = children;
|
351
|
+
stackConfigObj.activeColumn = activeColumn;
|
352
|
+
}
|
353
|
+
stackOptions.push(stackConfigObj);
|
323
354
|
}
|
324
355
|
|
356
|
+
obj.columnStack = {};
|
357
|
+
obj.columnStack.stacks = stackOptions;
|
358
|
+
obj.columnStack.autoStacking = this._autoStacking;
|
359
|
+
|
325
360
|
return obj;
|
326
361
|
};
|
327
362
|
|
@@ -390,6 +425,7 @@ ColumnStackPlugin.prototype._setColumnStackOptions = function(colIndex, stackOpt
|
|
390
425
|
ColumnStackPlugin.prototype._transformStackConfig = function(stackConfig) {
|
391
426
|
stackConfig.colRefs = [];
|
392
427
|
var children = stackConfig.children;
|
428
|
+
var fields = stackConfig.fields;
|
393
429
|
var activeColumn = stackConfig.activeColumn;
|
394
430
|
var field;
|
395
431
|
if(children){
|
@@ -401,15 +437,16 @@ ColumnStackPlugin.prototype._transformStackConfig = function(stackConfig) {
|
|
401
437
|
stackConfig.colRefs.push(field);
|
402
438
|
}
|
403
439
|
}
|
440
|
+
} else if(fields) {
|
441
|
+
stackConfig.colRefs = fields;
|
404
442
|
}
|
405
|
-
if(activeColumn){
|
443
|
+
if(activeColumn && !this._autoStacking){
|
406
444
|
var activeColIndex = this.getColumnIndex(activeColumn);
|
407
445
|
if(activeColIndex !== -1){
|
408
446
|
field = this._getField(colIndex);
|
409
447
|
if(field){
|
410
448
|
stackConfig.activeColumn;
|
411
449
|
}
|
412
|
-
|
413
450
|
}
|
414
451
|
}
|
415
452
|
return stackConfig;
|
@@ -859,21 +896,54 @@ ColumnStackPlugin.prototype.getStackId = function(colIndex) {
|
|
859
896
|
* @return {boolean} Return true if all of the given columns is stacked together
|
860
897
|
*/
|
861
898
|
ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options) {
|
862
|
-
var
|
899
|
+
var fields = [];
|
900
|
+
var i, colIndex, sid;
|
901
|
+
options = options || {};
|
902
|
+
|
903
|
+
if(stackId) {
|
904
|
+
if(this._stacks[stackId]) {
|
905
|
+
return false; // Cannot store the same stack Id
|
906
|
+
}
|
907
|
+
sid = stackId;
|
908
|
+
} else {
|
909
|
+
sid = this._generateStackId();
|
910
|
+
}
|
911
|
+
|
912
|
+
// If grid is not initialize, add setting to pending stacks
|
913
|
+
if(!this._initializedGrid) {
|
914
|
+
var pendingStacks = this._pendingStacks || {};
|
915
|
+
pendingStacks[sid] = {
|
916
|
+
colRefs: colRefs,
|
917
|
+
spreading: false,
|
918
|
+
collapsed: false,
|
919
|
+
activeColumn: options.activeColumn || colRefs[0]
|
920
|
+
};
|
921
|
+
this._pendingStacks = pendingStacks;
|
922
|
+
return false;
|
923
|
+
}
|
863
924
|
|
864
925
|
if(!colRefs) {
|
865
926
|
colRefs = this._getSelectedColumns();
|
866
927
|
}
|
867
928
|
|
868
929
|
if(colRefs.length) {
|
869
|
-
if(typeof colRefs[0] === "string") {
|
870
|
-
|
930
|
+
if(typeof colRefs[0] === "string") {
|
931
|
+
fields = colRefs.slice();
|
932
|
+
} else {
|
933
|
+
colRefs.sort(function(a, b) { return a - b; }); // Only sort in the case of column index stack
|
934
|
+
for(i = 0; i < colRefs.length; i++){
|
935
|
+
var field = this._getField(colRefs[i]);
|
936
|
+
fields.push(field);
|
937
|
+
}
|
871
938
|
}
|
872
939
|
colRefs = this.getColumnIndices(colRefs);
|
873
940
|
}
|
874
941
|
|
875
|
-
|
876
|
-
|
942
|
+
// Save stack fields for
|
943
|
+
if(this._autoStacking){
|
944
|
+
var columnStack = this._columnStack || {};
|
945
|
+
columnStack[sid] = fields;
|
946
|
+
this._columnStack = columnStack;
|
877
947
|
}
|
878
948
|
|
879
949
|
var len = colRefs.length;
|
@@ -883,17 +953,6 @@ ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options) {
|
|
883
953
|
if(!this.isColumnStackable(colRefs)) {
|
884
954
|
return false;
|
885
955
|
}
|
886
|
-
var sid;
|
887
|
-
if(stackId) {
|
888
|
-
if(this._stacks[stackId]) {
|
889
|
-
return false; // Cannot store the same stack Id
|
890
|
-
}
|
891
|
-
sid = stackId;
|
892
|
-
} else {
|
893
|
-
sid = this._generateStackId();
|
894
|
-
}
|
895
|
-
|
896
|
-
options = options || {};
|
897
956
|
|
898
957
|
var activeIndex = options.activeColumn ? this.getColumnIndices(options.activeColumn) : colRefs[0];
|
899
958
|
if (activeIndex.length){
|
@@ -912,7 +971,6 @@ ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options) {
|
|
912
971
|
}
|
913
972
|
stack.collapsed = options.collapsed !== false;
|
914
973
|
stack.stackRefs = new Array(len);
|
915
|
-
var i, colIndex;
|
916
974
|
for(i = 0; i < len; ++i) {
|
917
975
|
colIndex = colRefs[i];
|
918
976
|
this._setColumnStackOptions(colIndex, stack);
|
@@ -960,99 +1018,18 @@ ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options) {
|
|
960
1018
|
* @return {boolean} If the stack has been updated, return true.
|
961
1019
|
*/
|
962
1020
|
ColumnStackPlugin.prototype.setStack = function(colRefs, activeColRef) {
|
963
|
-
// Keep state
|
964
|
-
var i, colRef, type;
|
965
|
-
var fields = [];
|
966
|
-
if(Array.isArray(colRefs)) {
|
967
|
-
for (i = 0; i < colRefs.length; i++) {
|
968
|
-
colRef = colRefs[i];
|
969
|
-
type = typeof colRef;
|
970
|
-
if(type === "number") {
|
971
|
-
fields.push(this._getField(colRef));
|
972
|
-
} else if (type === "string") {
|
973
|
-
fields.push(colRef);
|
974
|
-
}
|
975
|
-
}
|
976
|
-
}
|
977
|
-
if(activeColRef && typeof activeColRef === "number") {
|
978
|
-
activeColRef = this._getField(activeColRef);
|
979
|
-
}
|
980
|
-
|
981
|
-
if(fields.length > 1) {
|
982
|
-
if(!this._columnStack) {
|
983
|
-
this._columnStack = {
|
984
|
-
spreading: false,
|
985
|
-
collapsed: false
|
986
|
-
};
|
987
|
-
}
|
988
|
-
this._columnStack.fields = fields;
|
989
|
-
} else {
|
990
|
-
this._columnStack = null;
|
991
|
-
}
|
992
1021
|
|
993
|
-
// Update UI
|
994
1022
|
var sid = "_uniqueStack"; // WARNING : This hardcode for assign uniqe stacking id
|
995
|
-
if(!this._initializedGrid) {
|
996
|
-
if(this._columnStack) {
|
997
|
-
var pendingStacks = {};
|
998
|
-
pendingStacks[sid] = {
|
999
|
-
colRefs: fields,
|
1000
|
-
spreading: false,
|
1001
|
-
collapsed: false
|
1002
|
-
};
|
1003
|
-
this._pendingStacks = pendingStacks;
|
1004
|
-
}
|
1005
|
-
return false;
|
1006
|
-
}
|
1007
|
-
|
1008
|
-
colRefs = this.getColumnIndices(colRefs);
|
1009
|
-
if(colRefs.length <= 1) { // When the array is empty or contains only one element, all stacking is removed
|
1010
|
-
return this.removeAllStacks();
|
1011
|
-
}
|
1012
|
-
|
1013
|
-
var activeIndex = colRefs[0]; // For the active index, choose the first element.
|
1014
|
-
if(activeColRef){
|
1015
|
-
var indices = this.getColumnIndices(activeColRef);
|
1016
|
-
if(indices.length){
|
1017
|
-
var index = indices[0];
|
1018
|
-
if(colRefs.indexOf(index) !== -1){
|
1019
|
-
activeIndex = indices[0];
|
1020
|
-
}
|
1021
|
-
}
|
1022
|
-
}
|
1023
|
-
|
1024
|
-
this.removeAllStacks(false); // Remove the stack without updating the UI (UI will only update when column is stacked)
|
1025
1023
|
|
1026
|
-
|
1027
|
-
var stack = {};
|
1028
|
-
stack.stackId = sid;
|
1029
|
-
stack.spreading = false;
|
1030
|
-
stack.stackRefs = new Array(colRefs.length);
|
1031
|
-
for(i = 0; i < colRefs.length; ++i) {
|
1032
|
-
var colIndex = colRefs[i];
|
1033
|
-
stack.stackRefs[i] = this._getColumnStacking(colIndex);
|
1034
|
-
this._setColumnStackOptions(colIndex, stack);
|
1024
|
+
this.removeAllStacks();
|
1035
1025
|
|
1036
|
-
|
1037
|
-
stack.activeColumn = stack.stackRefs[i];
|
1038
|
-
}
|
1026
|
+
var stackOptions = {};
|
1039
1027
|
|
1040
|
-
|
1041
|
-
|
1042
|
-
this._setColumnVisibility(colIndex, false);
|
1043
|
-
}
|
1028
|
+
if(activeColRef) {
|
1029
|
+
stackOptions.activeColumn = activeColRef;
|
1044
1030
|
}
|
1031
|
+
this.stackColumns(colRefs, sid, stackOptions);
|
1045
1032
|
|
1046
|
-
// Make sure that all columns stay packed together
|
1047
|
-
this._moveStackedColumns(stack.stackRefs);
|
1048
|
-
|
1049
|
-
// stack.activeColumn = stack.stackRefs[0]; // The first stacking (the first given columns) is the active column
|
1050
|
-
this._stacks[sid] = stack;
|
1051
|
-
var cfp = this._getPlugin("ColumnFilterPlugin");
|
1052
|
-
if(cfp) {
|
1053
|
-
cfp["refresh"]();
|
1054
|
-
}
|
1055
|
-
this._updateUI(); // asyncronuos
|
1056
1033
|
return true;
|
1057
1034
|
};
|
1058
1035
|
/** @public
|
@@ -1095,11 +1072,7 @@ ColumnStackPlugin.prototype.unstackColumns = function(colIndices) {
|
|
1095
1072
|
|
1096
1073
|
var stackRefs = stack.stackRefs;
|
1097
1074
|
len = stackRefs.length;
|
1098
|
-
|
1099
|
-
selFrom = this._getColumnIndex(stack.stackRefs[0]);
|
1100
|
-
} else {
|
1101
|
-
selFrom = this._getColumnIndex(stack.activeColumn);
|
1102
|
-
}
|
1075
|
+
selFrom = this._getColumnIndex(stack.stackRefs[0]);
|
1103
1076
|
selLen = len - 1;
|
1104
1077
|
|
1105
1078
|
for(i = 0; i < len; ++i) {
|
@@ -1109,6 +1082,9 @@ ColumnStackPlugin.prototype.unstackColumns = function(colIndices) {
|
|
1109
1082
|
this._setColumnVisibility(colIndex, true);
|
1110
1083
|
}
|
1111
1084
|
|
1085
|
+
if(this._autoStacking) {
|
1086
|
+
delete this._columnStack[sid];
|
1087
|
+
}
|
1112
1088
|
delete this._stacks[sid]; // Remove all reference to the stack
|
1113
1089
|
}
|
1114
1090
|
if(dirty) {
|
@@ -1150,6 +1126,7 @@ ColumnStackPlugin.prototype.removeAllStacks = function(enableUpdateUI) {
|
|
1150
1126
|
}
|
1151
1127
|
}
|
1152
1128
|
if(dirty) {
|
1129
|
+
this._columnStack = {};
|
1153
1130
|
this._stacks = {};
|
1154
1131
|
if(!disableUpdateUI) {
|
1155
1132
|
this._updateUI(); // asyncronous
|
@@ -1390,7 +1367,7 @@ ColumnStackPlugin.prototype._onColumnAdded = function (e) {
|
|
1390
1367
|
|
1391
1368
|
var columnStack = this._columnStack;
|
1392
1369
|
if (columnStack) {
|
1393
|
-
this._setStack();
|
1370
|
+
this._setStack(); //asynchronous
|
1394
1371
|
} else {
|
1395
1372
|
// add to group
|
1396
1373
|
var leftStackOpt = this._getColumnStackOptions(colIndex - 1);
|
@@ -1441,7 +1418,8 @@ ColumnStackPlugin.prototype._onStackButtonClicked = function(e) {
|
|
1441
1418
|
menuData[i] = {
|
1442
1419
|
value: i,
|
1443
1420
|
selected: i === activeIndex,
|
1444
|
-
label: this.getColumnName(colIndices[i])
|
1421
|
+
label: this.getColumnName(colIndices[i]),
|
1422
|
+
field: this._getField(colIndices[i])
|
1445
1423
|
};
|
1446
1424
|
}
|
1447
1425
|
pos["menuData"] = menuData;
|
@@ -1464,10 +1442,13 @@ ColumnStackPlugin.prototype._setStack = function() {
|
|
1464
1442
|
|
1465
1443
|
var columnStack = this._columnStack;
|
1466
1444
|
if(columnStack){
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
this.
|
1445
|
+
this.removeAllStacks(false);
|
1446
|
+
for(var sid in columnStack){
|
1447
|
+
var fields = columnStack[sid];
|
1448
|
+
var colIndices = this.getColumnIndices(fields);
|
1449
|
+
if (colIndices.length > 1) {
|
1450
|
+
this.stackColumns(fields, sid);
|
1451
|
+
}
|
1471
1452
|
}
|
1472
1453
|
}
|
1473
1454
|
};
|
@@ -1543,6 +1524,25 @@ ColumnStackPlugin.prototype.getColumnIndicesByColumnIds = function(columnId) {
|
|
1543
1524
|
return colIndices;
|
1544
1525
|
};
|
1545
1526
|
|
1527
|
+
/** @public
|
1528
|
+
* @description Get column ids by fields
|
1529
|
+
* @param {string|Array<string>} field
|
1530
|
+
* @return {!Array.<string>} Column indices
|
1531
|
+
*/
|
1532
|
+
ColumnStackPlugin.prototype.getColumnIdsByFields = function(field) {
|
1533
|
+
var colIndices = [];
|
1534
|
+
var fields = [];
|
1535
|
+
if(Array.isArray(field)){
|
1536
|
+
fields = field;
|
1537
|
+
} else {
|
1538
|
+
fields.push(field);
|
1539
|
+
}
|
1540
|
+
|
1541
|
+
colIndices = this.getColumnIndices(field);
|
1542
|
+
|
1543
|
+
return this.getColumnIdsByIndex(colIndices);
|
1544
|
+
};
|
1545
|
+
|
1546
1546
|
/** @public
|
1547
1547
|
* @description Add specific column to a stack
|
1548
1548
|
* @param {number|string} colRef column field or column index
|
@@ -1731,6 +1731,23 @@ ColumnStackPlugin.prototype.getStackName = function(stackId) {
|
|
1731
1731
|
return stackName;
|
1732
1732
|
};
|
1733
1733
|
|
1734
|
+
/** @public
|
1735
|
+
* @description Get active column field of specific stack
|
1736
|
+
* @param {string} stackId
|
1737
|
+
* @return {string} active column field
|
1738
|
+
*/
|
1739
|
+
ColumnStackPlugin.prototype.getActiveColumnField = function(stackId) {
|
1740
|
+
var field = "";
|
1741
|
+
if(stackId !== null) {
|
1742
|
+
var stack = this._stacks[stackId];
|
1743
|
+
if(stack){
|
1744
|
+
var activeColIndex = this._getColumnIndex(stack.activeColumn);
|
1745
|
+
field = this._getField(activeColIndex);
|
1746
|
+
}
|
1747
|
+
}
|
1748
|
+
return field;
|
1749
|
+
};
|
1750
|
+
|
1734
1751
|
|
1735
1752
|
export default ColumnStackPlugin;
|
1736
1753
|
export { ColumnStackPlugin, ColumnStackPlugin as ColumnStack, ColumnStackPlugin as ColumnStackExtension };
|
@@ -16,6 +16,7 @@ import { CoralItems } from '../../tr-grid-util/es6/CoralItems.js';
|
|
16
16
|
* @property {string=} placeholder="" Placeholder text inside the input
|
17
17
|
* @property {string=} type="text" Type of UI. Available types are "number", "select", "dropdown", "date"
|
18
18
|
* @property {Array=} entries Entries of dropdown filters when type is "select"
|
19
|
+
* @property {*} defaultValue Default value of input filter
|
19
20
|
* @property {string=} trigger="keyup" Available types of trigger are `false | ""` (no trigger) , `"keyup"` (default) , `"enter"` (on enter key *only available for text type)
|
20
21
|
*/
|
21
22
|
|
@@ -275,6 +276,10 @@ FilterInputPlugin.prototype.getConfigObject = function (out_obj) {
|
|
275
276
|
filterInput.entries = opt.entries;
|
276
277
|
}
|
277
278
|
|
279
|
+
if (opt.defaultValue != null) {
|
280
|
+
filterInput.defaultValue = opt.defaultValue;
|
281
|
+
}
|
282
|
+
|
278
283
|
if (opt.trigger != null) {
|
279
284
|
filterInput.trigger = opt.trigger;
|
280
285
|
}
|
@@ -455,6 +460,17 @@ FilterInputPlugin.prototype._createColumnInputs = function (section, host) {
|
|
455
460
|
}
|
456
461
|
|
457
462
|
this._dispatch("inputCreated", inputArgs);
|
463
|
+
|
464
|
+
var defaultValue = colOpt.defaultValue;
|
465
|
+
|
466
|
+
if (defaultValue) {
|
467
|
+
if (colOpt.type == "date") {
|
468
|
+
var dateObj = ElfDate.from(defaultValue);
|
469
|
+
defaultValue = dateObj ? dateObj.toDateString().substr(4) : "";
|
470
|
+
}
|
471
|
+
|
472
|
+
this.filterColumn(c, defaultValue);
|
473
|
+
}
|
458
474
|
}
|
459
475
|
};
|
460
476
|
/** @type {Object.<string, string>=}
|
@@ -475,6 +491,7 @@ FilterInputPlugin._uiMap = {
|
|
475
491
|
|
476
492
|
FilterInputPlugin.prototype._createFilterUI = function (colOpt) {
|
477
493
|
var elemType = colOpt.type;
|
494
|
+
var defaultValue = colOpt.defaultValue;
|
478
495
|
var elemTrigger = colOpt.trigger != null ? colOpt.trigger : this._inputTrigger;
|
479
496
|
var uiTag = FilterInputPlugin._uiMap[elemType] || "input";
|
480
497
|
|
@@ -502,6 +519,10 @@ FilterInputPlugin.prototype._createFilterUI = function (colOpt) {
|
|
502
519
|
elem.addEventListener("keydown", FilterInputPlugin._stopPropagation, false);
|
503
520
|
elem.addEventListener("click", FilterInputPlugin._stopPropagation, false);
|
504
521
|
|
522
|
+
if (defaultValue) {
|
523
|
+
elem.value = colOpt.defaultValue;
|
524
|
+
}
|
525
|
+
|
505
526
|
switch (uiTag) {
|
506
527
|
case "ef-input":
|
507
528
|
elem.setAttribute("type", "number");
|
@@ -652,6 +673,12 @@ FilterInputPlugin.prototype._retrieveColumnOption = function (colIndex, colDef)
|
|
652
673
|
option["entries"] = entries;
|
653
674
|
}
|
654
675
|
|
676
|
+
var defaultValue = filterOption["defaultValue"];
|
677
|
+
|
678
|
+
if (defaultValue) {
|
679
|
+
option["defaultValue"] = defaultValue;
|
680
|
+
}
|
681
|
+
|
655
682
|
var trigger = filterOption["trigger"];
|
656
683
|
|
657
684
|
if (typeof trigger == "string" || trigger == false) {
|