@refinitiv-ui/efx-grid 6.0.69 → 6.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/column-selection-dialog/lib/column-selection-dialog.js +19 -7
- package/lib/core/dist/core.js +38 -3
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/grid/Core.d.ts +2 -0
- package/lib/core/es6/grid/Core.js +30 -2
- package/lib/core/es6/grid/VirtualizedLayoutGrid.js +8 -1
- package/lib/filter-dialog/lib/filter-dialog.js +90 -51
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +52 -17
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.d.ts +5 -2
- package/lib/rt-grid/es6/Grid.js +22 -15
- package/lib/tr-grid-column-selection/es6/ColumnSelection.js +7 -27
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +7 -1
- package/lib/tr-grid-filter-input/es6/FilterInput.js +9 -3
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.d.ts +3 -2
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +65 -18
- package/lib/tr-grid-printer/es6/CellWriter.d.ts +5 -5
- package/lib/tr-grid-printer/es6/CellWriter.js +6 -6
- package/lib/tr-grid-printer/es6/GridPrinter.d.ts +7 -6
- package/lib/tr-grid-printer/es6/GridPrinter.js +4 -2
- package/lib/tr-grid-printer/es6/PrintTrait.d.ts +1 -1
- package/lib/tr-grid-printer/es6/SectionWriter.d.ts +1 -1
- package/lib/tr-grid-row-dragging/es6/RowDragging.js +65 -0
- package/lib/tr-grid-row-filtering/es6/RowFiltering.d.ts +1 -3
- package/lib/tr-grid-row-filtering/es6/RowFiltering.js +235 -114
- package/lib/tr-grid-row-selection/es6/RowSelection.js +14 -32
- package/lib/tr-grid-titlewrap/es6/TitleWrap.d.ts +2 -2
- package/lib/tr-grid-titlewrap/es6/TitleWrap.js +1 -1
- package/lib/tr-grid-util/es6/GridPlugin.js +52 -0
- package/lib/types/es6/Core/grid/Core.d.ts +2 -0
- package/lib/types/es6/InCellEditing.d.ts +3 -2
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +5 -2
- package/lib/types/es6/RowFiltering.d.ts +1 -3
- package/lib/types/es6/TitleWrap.d.ts +2 -2
- package/lib/versions.json +14 -14
- package/package.json +1 -1
@@ -24,6 +24,14 @@ import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
|
|
24
24
|
* },
|
25
25
|
*/
|
26
26
|
|
27
|
+
/** @event RowFilteringPlugin#dialogCommitted
|
28
|
+
* @description Fired after a user clicks done button from the filter dialog or changes sort order.
|
29
|
+
* @property {number} colIndex
|
30
|
+
* @property {Object=} value When filter is changed, the change will be passed through this property
|
31
|
+
* @property {number=} sortOrder When sort order is changed, the change will be passed through this property
|
32
|
+
* @property {string=} fieldDataType
|
33
|
+
*/
|
34
|
+
|
27
35
|
/** @event RowFilteringPlugin#iconCreated
|
28
36
|
* @description iconCreated event is dispatched when a new column filter icon is created.
|
29
37
|
* @property {Element} icon Filter icon element
|
@@ -61,7 +69,7 @@ The expression can take various forms:<br>
|
|
61
69
|
*/
|
62
70
|
|
63
71
|
/** @typedef {Object} RowFilteringPlugin~FilterExpression
|
64
|
-
* @description FilterExpression contains all data used for saving and restoring filter in a column
|
72
|
+
* @description Deprecated. FilterExpression contains all data used for saving and restoring filter in a column
|
65
73
|
* @property {string} field
|
66
74
|
* @property {RowFilteringPlugin~Expression} expression Expression representing filter function
|
67
75
|
* @property {*} context Context object contains context/states given by user
|
@@ -307,6 +315,8 @@ RowFilteringPlugin.prototype.unload = function (host) {
|
|
307
315
|
host.unlisten("columnRemoved", this._onColumnRemoved);
|
308
316
|
|
309
317
|
if (!this._hosts.length) {
|
318
|
+
this._hasPendingFilter = false;
|
319
|
+
|
310
320
|
if (this._filterDialog) {
|
311
321
|
this._filterDialog.hide(); // Remove the dialog from document
|
312
322
|
|
@@ -335,6 +345,34 @@ RowFilteringPlugin.prototype._afterInit = function () {
|
|
335
345
|
setTimeout(this._onPreLoadedDialog, 10);
|
336
346
|
}
|
337
347
|
}
|
348
|
+
|
349
|
+
this._applyPendingFilter();
|
350
|
+
};
|
351
|
+
/** @private
|
352
|
+
*/
|
353
|
+
|
354
|
+
|
355
|
+
RowFilteringPlugin.prototype._applyPendingFilter = function () {
|
356
|
+
if (!this._initializedGrid) {
|
357
|
+
return;
|
358
|
+
}
|
359
|
+
|
360
|
+
if (!this._hasPendingFilter) {
|
361
|
+
return;
|
362
|
+
}
|
363
|
+
|
364
|
+
this._hasPendingFilter = false;
|
365
|
+
var colCount = this.getColumnCount();
|
366
|
+
|
367
|
+
for (var c = 0; c < colCount; ++c) {
|
368
|
+
var colSettings = this._getUserColumnSettings(c);
|
369
|
+
|
370
|
+
if (colSettings.expression) {
|
371
|
+
this.addColumnFilter(c, colSettings.expression, colSettings.filterState);
|
372
|
+
} else {
|
373
|
+
this._removeColumnFilters(c);
|
374
|
+
}
|
375
|
+
}
|
338
376
|
};
|
339
377
|
/** @private
|
340
378
|
*/
|
@@ -405,6 +443,7 @@ RowFilteringPlugin.prototype.config = function (options) {
|
|
405
443
|
|
406
444
|
this.addListener(rowFiltering, "click");
|
407
445
|
this.addListener(rowFiltering, "beforeDialogOpened");
|
446
|
+
this.addListener(rowFiltering, "dialogCommitted");
|
408
447
|
this.addListener(rowFiltering, "iconCreated");
|
409
448
|
this.addListener(rowFiltering, "filterChanged");
|
410
449
|
this.addListener(rowFiltering, "refreshed");
|
@@ -424,6 +463,8 @@ RowFilteringPlugin.prototype.config = function (options) {
|
|
424
463
|
|
425
464
|
this._setColumnOptions(i, column);
|
426
465
|
}
|
466
|
+
|
467
|
+
this._applyPendingFilter();
|
427
468
|
};
|
428
469
|
/** @public
|
429
470
|
* @param {Object=} gridOptions
|
@@ -448,22 +489,20 @@ RowFilteringPlugin.prototype.getConfigObject = function (gridOptions) {
|
|
448
489
|
column = columns[i] = {};
|
449
490
|
}
|
450
491
|
|
451
|
-
var
|
492
|
+
var colSettings = this._getUserColumnSettings(i);
|
452
493
|
|
453
|
-
|
454
|
-
var exp = cfo._expressions[0];
|
494
|
+
var exp = colSettings.expression;
|
455
495
|
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
496
|
+
if (exp && typeof exp !== "function") {
|
497
|
+
// TODO: Accept function type
|
498
|
+
column.filter = exp; // This could be string, array, or object
|
499
|
+
}
|
460
500
|
|
461
|
-
|
501
|
+
var ctx = colSettings.filterState;
|
462
502
|
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
}
|
503
|
+
if (ctx != null) {
|
504
|
+
if (_typeof(ctx) !== "object" || !ctx._autoGenerated) {
|
505
|
+
column.filterState = ctx;
|
467
506
|
}
|
468
507
|
}
|
469
508
|
}
|
@@ -655,7 +694,10 @@ RowFilteringPlugin.prototype.addColumnFilter = function (colIndex, exp, ctx) {
|
|
655
694
|
func =
|
656
695
|
/** @type{Function} */
|
657
696
|
exp;
|
658
|
-
|
697
|
+
|
698
|
+
if (ctx && typeof ctx === "string") {
|
699
|
+
exp = ctx;
|
700
|
+
}
|
659
701
|
} else {
|
660
702
|
func = this._parseFilter(exp, colIndex, ctx);
|
661
703
|
}
|
@@ -664,6 +706,16 @@ RowFilteringPlugin.prototype.addColumnFilter = function (colIndex, exp, ctx) {
|
|
664
706
|
return false;
|
665
707
|
}
|
666
708
|
|
709
|
+
if (colIndex < 0 || colIndex >= this.getColumnCount()) {
|
710
|
+
return false;
|
711
|
+
}
|
712
|
+
|
713
|
+
var colSettings = this._getUserColumnSettings(colIndex);
|
714
|
+
|
715
|
+
colSettings.expression = exp; // WARNING: Only the last expression are saved (previous one is overwritten)
|
716
|
+
|
717
|
+
colSettings.filterState = ctx;
|
718
|
+
|
667
719
|
if (ctx == null) {
|
668
720
|
ctx = {
|
669
721
|
"_autoGenerated": true
|
@@ -712,10 +764,28 @@ RowFilteringPlugin.prototype.addColumnFilter = function (colIndex, exp, ctx) {
|
|
712
764
|
* @param {(Object|string)=} ctx Context object that will be passed as the third parameter for the filter logic
|
713
765
|
* @return {boolean} True If there is any change
|
714
766
|
* @fires RowFilteringPlugin#filterChanged
|
767
|
+
* @example
|
768
|
+
* extension.setColumnFilter(colIndex1,
|
769
|
+
* [["GT", 0]]
|
770
|
+
* );
|
771
|
+
* extension.setColumnFilter(colIndex2,
|
772
|
+
* "filter": "[PCTCHNG] > 0"
|
773
|
+
* );
|
774
|
+
* extension.setColumnFilter(colIndex3,
|
775
|
+
* function(rowData) {
|
776
|
+
* return rowData["PCTCHNG"] > 0;
|
777
|
+
* }
|
778
|
+
* );
|
715
779
|
*/
|
716
780
|
|
717
781
|
|
718
782
|
RowFilteringPlugin.prototype.setColumnFilter = function (colIndex, exp, ctx) {
|
783
|
+
var curExp = this._getColumnExpression(colIndex);
|
784
|
+
|
785
|
+
if (curExp === exp) {
|
786
|
+
return false;
|
787
|
+
}
|
788
|
+
|
719
789
|
var removed = this._removeColumnFilters(colIndex);
|
720
790
|
|
721
791
|
var added = this.addColumnFilter(colIndex, exp, ctx);
|
@@ -726,71 +796,88 @@ RowFilteringPlugin.prototype.setColumnFilter = function (colIndex, exp, ctx) {
|
|
726
796
|
|
727
797
|
return removed || added;
|
728
798
|
};
|
799
|
+
/** @private
|
800
|
+
* @param {number} colIndex
|
801
|
+
* @return {RowFilteringPlugin~Expression}
|
802
|
+
*/
|
803
|
+
|
804
|
+
|
805
|
+
RowFilteringPlugin.prototype._getColumnExpression = function (colIndex) {
|
806
|
+
var colSettings = this._getUserColumnSettings(colIndex);
|
807
|
+
|
808
|
+
return colSettings.expression || null;
|
809
|
+
};
|
729
810
|
/** Set data to colData["rowFiltering"]
|
730
811
|
* @private
|
731
812
|
* @param {number} colIndex
|
732
|
-
* @param {RowFilteringPlugin~ColumnOptions}
|
813
|
+
* @param {RowFilteringPlugin~ColumnOptions} userObj
|
733
814
|
* @example
|
734
|
-
* var
|
735
|
-
* "
|
815
|
+
* var colDef1 = {
|
816
|
+
* "field": "PCTCHNG",
|
817
|
+
* "filter": [["GT", 0]]
|
736
818
|
* };
|
737
819
|
* var colDef2 = {
|
738
820
|
* "filter": "[PCTCHNG] > 0"
|
739
821
|
* };
|
740
822
|
* var colDef3 = {
|
741
|
-
* "filter": function() {
|
823
|
+
* "filter": function(rowData) {
|
824
|
+
* return rowData["PCTCHNG"] > 0;
|
825
|
+
* }
|
742
826
|
* };
|
743
827
|
*/
|
744
828
|
|
745
829
|
|
746
|
-
RowFilteringPlugin.prototype._setColumnOptions = function (colIndex,
|
747
|
-
var
|
830
|
+
RowFilteringPlugin.prototype._setColumnOptions = function (colIndex, userObj) {
|
831
|
+
var colSettings = this._getUserColumnSettings(colIndex);
|
748
832
|
|
749
|
-
var filterIcon =
|
750
|
-
|
833
|
+
var filterIcon = userObj["filterIcon"]; // TODO: This should not be set here, should retreive data type from Composite/Realtime Grid
|
834
|
+
|
835
|
+
var fieldDataType = userObj["fieldDataType"] || userObj["dataType"];
|
751
836
|
|
752
837
|
if (fieldDataType) {
|
753
|
-
|
838
|
+
colSettings.fieldDataType = fieldDataType; // TODO: This should not be set here, should retreive data type from Composite/Realtime Grid
|
754
839
|
}
|
755
840
|
|
756
841
|
if (filterIcon != null) {
|
757
|
-
|
842
|
+
colSettings.filterIcon = filterIcon;
|
758
843
|
}
|
759
844
|
|
760
|
-
var
|
761
|
-
var exp = columnOptions["filter"];
|
845
|
+
var exp = userObj["filter"];
|
762
846
|
|
763
|
-
if (exp) {
|
764
|
-
|
765
|
-
|
766
|
-
this.
|
847
|
+
if (exp != null) {
|
848
|
+
colSettings.expression = exp;
|
849
|
+
colSettings.filterState = null;
|
850
|
+
this._hasPendingFilter = true;
|
767
851
|
}
|
768
|
-
};
|
769
|
-
/** @private
|
770
|
-
* @param {number} colIndex
|
771
|
-
* @return {Object} colData["rowFiltering"]
|
772
|
-
*/
|
773
852
|
|
853
|
+
var filterState = userObj["filterState"];
|
854
|
+
|
855
|
+
if (filterState != null) {
|
856
|
+
colSettings.filterState = filterState;
|
857
|
+
}
|
858
|
+
|
859
|
+
var iconActivation = filterIcon == false ? "none" : this._iconActivation;
|
774
860
|
|
775
|
-
|
776
|
-
|
861
|
+
if (iconActivation == "always" || iconActivation == "onHover") {
|
862
|
+
this._updateColumnIcon(colIndex);
|
863
|
+
}
|
777
864
|
};
|
778
865
|
/** @private
|
779
866
|
* @param {number} colIndex
|
780
|
-
* @return {!Object}
|
867
|
+
* @return {!Object} colData["rowFiltering"]
|
781
868
|
*/
|
782
869
|
|
783
870
|
|
784
|
-
RowFilteringPlugin.prototype.
|
785
|
-
var
|
871
|
+
RowFilteringPlugin.prototype._getUserColumnSettings = function (colIndex) {
|
872
|
+
var colData = this._newColumnData(colIndex);
|
786
873
|
|
787
|
-
var
|
874
|
+
var colSettings = colData["rowFiltering"];
|
788
875
|
|
789
|
-
if (!
|
790
|
-
|
876
|
+
if (!colSettings) {
|
877
|
+
colSettings = colData["rowFiltering"] = {};
|
791
878
|
}
|
792
879
|
|
793
|
-
return
|
880
|
+
return colSettings;
|
794
881
|
};
|
795
882
|
/** @private
|
796
883
|
* @param {number} colIndex
|
@@ -799,40 +886,37 @@ RowFilteringPlugin.prototype._newExtColumnOptions = function (colIndex) {
|
|
799
886
|
|
800
887
|
|
801
888
|
RowFilteringPlugin.prototype._getColumnFilterOption = function (colIndex) {
|
802
|
-
var
|
889
|
+
var colSettings = this._getUserColumnSettings(colIndex);
|
803
890
|
|
804
|
-
if (
|
805
|
-
return
|
891
|
+
if (colSettings) {
|
892
|
+
return colSettings["filterOption"] || null;
|
806
893
|
} else {
|
807
894
|
return null;
|
808
895
|
}
|
809
896
|
};
|
810
|
-
/**
|
897
|
+
/** Remove colData["rowFiltering"]["filterOption"]
|
811
898
|
* @private
|
812
899
|
* @param {number} colIndex
|
813
|
-
* @param {Object} filterOption
|
814
900
|
*/
|
815
901
|
|
816
902
|
|
817
|
-
RowFilteringPlugin.prototype.
|
818
|
-
var
|
819
|
-
|
820
|
-
if (filterOption) {
|
821
|
-
colOptions["filterOption"] = filterOption;
|
822
|
-
} else {
|
823
|
-
var cfo = colOptions["filterOption"];
|
903
|
+
RowFilteringPlugin.prototype._removeActiveFilterStates = function (colIndex) {
|
904
|
+
var colSettings = this._getUserColumnSettings(colIndex);
|
824
905
|
|
825
|
-
|
826
|
-
|
906
|
+
colSettings.expression = null;
|
907
|
+
colSettings.filterState = null;
|
908
|
+
var cfo = colSettings["filterOption"];
|
827
909
|
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
910
|
+
if (cfo) {
|
911
|
+
colSettings["filterOption"] = null;
|
912
|
+
|
913
|
+
if (cfo._filters.length) {
|
914
|
+
this._dispatch("filterChanged", {
|
915
|
+
"filterType": "column",
|
916
|
+
"changeType": "remove",
|
917
|
+
"colIndex": colIndex,
|
918
|
+
"field": this._getField(colIndex)
|
919
|
+
});
|
836
920
|
}
|
837
921
|
}
|
838
922
|
};
|
@@ -851,7 +935,9 @@ RowFilteringPlugin.prototype._initColumnFilterOption = function (colIndex) {
|
|
851
935
|
cfo._expressions = [];
|
852
936
|
cfo._context = [];
|
853
937
|
|
854
|
-
this.
|
938
|
+
var colSettings = this._getUserColumnSettings(colIndex);
|
939
|
+
|
940
|
+
colSettings["filterOption"] = cfo;
|
855
941
|
}
|
856
942
|
|
857
943
|
return cfo;
|
@@ -907,6 +993,7 @@ RowFilteringPlugin.prototype.removeFilter = function (funcRef) {
|
|
907
993
|
* @public
|
908
994
|
* @param {number} colIndex
|
909
995
|
* @return {boolean} True if there is any change
|
996
|
+
* @fires RowFilteringPlugin#filterChanged
|
910
997
|
*/
|
911
998
|
|
912
999
|
|
@@ -927,6 +1014,7 @@ RowFilteringPlugin.prototype.removeColumnFilters = function (colIndex) {
|
|
927
1014
|
/** @private
|
928
1015
|
* @param {number} colIndex
|
929
1016
|
* @return {boolean} True if there is any change
|
1017
|
+
* @fires RowFilteringPlugin#filterChanged
|
930
1018
|
*/
|
931
1019
|
|
932
1020
|
|
@@ -940,7 +1028,7 @@ RowFilteringPlugin.prototype._removeColumnFilters = function (colIndex) {
|
|
940
1028
|
this._columnFilters.splice(funcIndex, 1);
|
941
1029
|
}
|
942
1030
|
|
943
|
-
this.
|
1031
|
+
this._removeActiveFilterStates(colIndex); // filterChanged fired
|
944
1032
|
|
945
1033
|
|
946
1034
|
var inputExt = this._getPlugin("FilterInputPlugin"); // TODO: Use the event instead
|
@@ -958,6 +1046,7 @@ RowFilteringPlugin.prototype._removeColumnFilters = function (colIndex) {
|
|
958
1046
|
* @function
|
959
1047
|
* @param {number} colIndex
|
960
1048
|
* @return {boolean} True if there is any change
|
1049
|
+
* @fires RowFilteringPlugin#filterChanged
|
961
1050
|
*/
|
962
1051
|
|
963
1052
|
|
@@ -965,6 +1054,7 @@ RowFilteringPlugin.prototype.removeColumnFilter = RowFilteringPlugin.prototype.r
|
|
965
1054
|
/** Remove all column filters from all columns, excluding global filters
|
966
1055
|
* @public
|
967
1056
|
* @return {boolean} Return true if there is any change
|
1057
|
+
* @fires RowFilteringPlugin#filterChanged
|
968
1058
|
*/
|
969
1059
|
|
970
1060
|
RowFilteringPlugin.prototype.removeAllColumnFilters = function () {
|
@@ -976,7 +1066,7 @@ RowFilteringPlugin.prototype.removeAllColumnFilters = function () {
|
|
976
1066
|
var colCount = this._getColumnCount();
|
977
1067
|
|
978
1068
|
for (var i = 0; i < colCount; ++i) {
|
979
|
-
this.
|
1069
|
+
this._removeActiveFilterStates(i); // filterChanged fired
|
980
1070
|
|
981
1071
|
|
982
1072
|
inputExt && inputExt.updateUI(i, ""); // TODO: Use the event instead
|
@@ -1054,10 +1144,10 @@ RowFilteringPlugin.prototype.setRowTransform = function (func) {
|
|
1054
1144
|
RowFilteringPlugin.prototype.getFilters = function () {
|
1055
1145
|
return this._globalFilters;
|
1056
1146
|
};
|
1057
|
-
/**
|
1147
|
+
/** Returns filter functions. Use getConfigObject for saving and loading instead of this function
|
1058
1148
|
* @public
|
1059
1149
|
* @return {!Array.<Function>} All column filters
|
1060
|
-
* @see {@link RowFilteringPlugin.
|
1150
|
+
* @see {@link RowFilteringPlugin.getConfigObject}
|
1061
1151
|
*/
|
1062
1152
|
|
1063
1153
|
|
@@ -1076,21 +1166,22 @@ RowFilteringPlugin.prototype.getAllColumnFilters = function () {
|
|
1076
1166
|
|
1077
1167
|
return filters;
|
1078
1168
|
};
|
1079
|
-
/** Get existing filter expressions for saving and restoring.
|
1169
|
+
/** Deprecated in favor of getConfigObject(). Get existing filter expressions for saving and restoring.
|
1080
1170
|
* @public
|
1081
1171
|
* @return {Array.<RowFilteringPlugin~FilterExpression>} Return null if there is no column filter
|
1082
|
-
* @see {@link RowFilteringPlugin.
|
1172
|
+
* @see {@link RowFilteringPlugin.getConfigObject}
|
1083
1173
|
*/
|
1084
1174
|
|
1085
1175
|
|
1086
1176
|
RowFilteringPlugin.prototype.getFilterExpressions = function () {
|
1087
1177
|
if (this._columnFilters.length) {
|
1178
|
+
// TODO: Provide a way to save rawDataAccessor and formattedDataAccessor
|
1088
1179
|
return this._columnFilters.map(toFilterExpression);
|
1089
1180
|
}
|
1090
1181
|
|
1091
1182
|
return null;
|
1092
1183
|
};
|
1093
|
-
/** Clear all existing column filters and restore column filters from the given valid filter expressions. If the parameter is null, the result is equivalent to calling removeAllColumnFilters();
|
1184
|
+
/** Deprecated. Clear all existing column filters and restore column filters from the given valid filter expressions. If the parameter is null, the result is equivalent to calling removeAllColumnFilters();
|
1094
1185
|
* @public
|
1095
1186
|
* @param {Array.<RowFilteringPlugin~FilterExpression>} filterExps
|
1096
1187
|
*/
|
@@ -1110,7 +1201,7 @@ RowFilteringPlugin.prototype.setFilterExpressions = function (filterExps) {
|
|
1110
1201
|
var colIndex = fields.indexOf(field);
|
1111
1202
|
|
1112
1203
|
if (colIndex >= 0) {
|
1113
|
-
this.
|
1204
|
+
this.setColumnFilter(colIndex, filterExp.expression, filterExp.context);
|
1114
1205
|
}
|
1115
1206
|
}
|
1116
1207
|
}
|
@@ -1349,11 +1440,13 @@ RowFilteringPlugin.prototype.refresh = function () {
|
|
1349
1440
|
|
1350
1441
|
|
1351
1442
|
RowFilteringPlugin.prototype._updateColumnIcon = function (colIndex) {
|
1352
|
-
var cfo = this._getColumnFilterOption(colIndex);
|
1443
|
+
var cfo = this._getColumnFilterOption(colIndex); // colData["rowFiltering"]["filterOption"]
|
1444
|
+
|
1353
1445
|
|
1354
|
-
var
|
1446
|
+
var colSettings = this._getUserColumnSettings(colIndex); // colData["rowFiltering"]
|
1355
1447
|
|
1356
|
-
|
1448
|
+
|
1449
|
+
var iconActivation = colSettings.filterIcon == false ? "none" : this._iconActivation;
|
1357
1450
|
var hasFilter = cfo ? cfo._filters.length : 0;
|
1358
1451
|
|
1359
1452
|
for (var i = this._hosts.length; --i >= 0;) {
|
@@ -1492,10 +1585,10 @@ RowFilteringPlugin.prototype.getColumnFilterState = function (colIndex) {
|
|
1492
1585
|
|
1493
1586
|
return null;
|
1494
1587
|
};
|
1495
|
-
/** Get the stored user context from all columns. The column with no filter will return null value
|
1588
|
+
/** Deprecated in favor of getConfigObject(). Get the stored user context from all columns. The column with no filter will return null value
|
1496
1589
|
* @public
|
1497
1590
|
* @return {!Array} Array of context objects
|
1498
|
-
* @see {@link RowFilteringPlugin.
|
1591
|
+
* @see {@link RowFilteringPlugin.getConfigObject}
|
1499
1592
|
*/
|
1500
1593
|
|
1501
1594
|
|
@@ -1549,16 +1642,19 @@ RowFilteringPlugin.prototype._getDataTable = function (dv) {
|
|
1549
1642
|
return dt;
|
1550
1643
|
};
|
1551
1644
|
/** @public
|
1645
|
+
* @ignore
|
1552
1646
|
* @param {string} field A field name for getting raw value from row data
|
1553
1647
|
* @param {Function=} formatter A formatter that takes row data, retrieves data, and modified the data for display.
|
1554
1648
|
* @param {string=} fmtField A field name to be used instead of formatter for getting formatted value
|
1555
1649
|
* @param {Function=} rawDataAccessor Data getter to retrieve raw value
|
1556
1650
|
* @param {Function=} formattedDataAccessor Data getter to retrieve formatted value. This paramter will override formatted and fmtField parameters
|
1651
|
+
* @param {Function=} filterFuncs
|
1652
|
+
* @param {Object=} selectedItems
|
1557
1653
|
* @return {Object} Object that maps formatted value to array of raw values
|
1558
1654
|
*/
|
1559
1655
|
|
1560
1656
|
|
1561
|
-
RowFilteringPlugin.prototype.getUniqueValues = function (field, formatter, fmtField, rawDataAccessor, formattedDataAccessor) {
|
1657
|
+
RowFilteringPlugin.prototype.getUniqueValues = function (field, formatter, fmtField, rawDataAccessor, formattedDataAccessor, filterFuncs, selectedItems) {
|
1562
1658
|
if (!field) {
|
1563
1659
|
return null;
|
1564
1660
|
}
|
@@ -1629,6 +1725,12 @@ RowFilteringPlugin.prototype.getUniqueValues = function (field, formatter, fmtFi
|
|
1629
1725
|
continue;
|
1630
1726
|
}
|
1631
1727
|
|
1728
|
+
if (filterFuncs) {
|
1729
|
+
if (!selectedItems[formattedVal]) {
|
1730
|
+
selectedItems[formattedVal] = RowFilteringPlugin._getFilteredValue(row, filterFuncs);
|
1731
|
+
}
|
1732
|
+
}
|
1733
|
+
|
1632
1734
|
var rawValues = uniqueValues[formattedVal];
|
1633
1735
|
|
1634
1736
|
if (rawValues) {
|
@@ -1668,6 +1770,23 @@ RowFilteringPlugin._createDialog = function () {
|
|
1668
1770
|
|
1669
1771
|
return tag ? document.createElement(tag) : null;
|
1670
1772
|
};
|
1773
|
+
/** @private
|
1774
|
+
* @function
|
1775
|
+
* @param {Object} rowData
|
1776
|
+
* @param {!Array.<Function>} filters
|
1777
|
+
* @returns {boolean}
|
1778
|
+
*/
|
1779
|
+
|
1780
|
+
|
1781
|
+
RowFilteringPlugin._getFilteredValue = function (rowData, filters) {
|
1782
|
+
for (var i = filters.length; --i >= 0;) {
|
1783
|
+
if (!filters[i](rowData)) {
|
1784
|
+
return false;
|
1785
|
+
}
|
1786
|
+
}
|
1787
|
+
|
1788
|
+
return true;
|
1789
|
+
};
|
1671
1790
|
/** @public
|
1672
1791
|
* @param {number} colIndex
|
1673
1792
|
* @param {RowFilteringPlugin~FilterDialogOptions=} runtimeDialogOptions
|
@@ -1767,13 +1886,6 @@ RowFilteringPlugin.prototype.openDialog = function (colIndex, runtimeDialogOptio
|
|
1767
1886
|
this._filterDialog.setSortState(stp.getSortOrder(colIndex)); // This is for ELF v3
|
1768
1887
|
|
1769
1888
|
} // Setting up dialog configuration
|
1770
|
-
// cfo is required for storing unique entries in the dialog, even though no filter is active
|
1771
|
-
|
1772
|
-
|
1773
|
-
var cfo = this._initColumnFilterOption(colIndex); // colData["rowFiltering"]["filterOption"]
|
1774
|
-
|
1775
|
-
|
1776
|
-
var colOptions = this._getExtColumnOptions(colIndex); // colData["rowFiltering"]
|
1777
1889
|
|
1778
1890
|
|
1779
1891
|
var colData = host.getColumnData(colIndex);
|
@@ -1802,36 +1914,53 @@ RowFilteringPlugin.prototype.openDialog = function (colIndex, runtimeDialogOptio
|
|
1802
1914
|
};
|
1803
1915
|
var columnDialogOptions = null;
|
1804
1916
|
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1917
|
+
var colSettings = this._getUserColumnSettings(colIndex); // colData["rowFiltering"]
|
1918
|
+
|
1919
|
+
|
1920
|
+
if (colSettings.fieldDataType) {
|
1921
|
+
// TODO: Use data type from Composite Grid (getColumnDataType) or Realtime Grid (getDataType) instead
|
1922
|
+
columnDialogOptions = {
|
1923
|
+
fieldDataType: colSettings.fieldDataType
|
1924
|
+
};
|
1812
1925
|
}
|
1813
1926
|
|
1814
1927
|
RowFilteringPlugin._overrideConfig(dialogConfig, this._dialogOptions);
|
1815
1928
|
|
1816
1929
|
RowFilteringPlugin._overrideConfig(dialogConfig, columnDialogOptions);
|
1817
1930
|
|
1818
|
-
RowFilteringPlugin._overrideConfig(dialogConfig, runtimeDialogOptions);
|
1931
|
+
RowFilteringPlugin._overrideConfig(dialogConfig, runtimeDialogOptions); // cfo is required for storing unique entries in the dialog, even though no filter is active
|
1932
|
+
// TODO: move rawDataAccessor and other settings to colSettings
|
1933
|
+
|
1934
|
+
|
1935
|
+
var cfo = this._initColumnFilterOption(colIndex); // colData["rowFiltering"]["filterOption"]
|
1936
|
+
|
1819
1937
|
|
1820
1938
|
var rawDataAccessor = cfo._rawDataAccessor = dialogConfig.rawDataAccessor || null;
|
1821
1939
|
var formattedDataAccessor = cfo._formattedDataAccessor = dialogConfig.formattedDataAccessor || null;
|
1822
1940
|
var sortLogic = dialogConfig.sortLogic || null; // Populate data for filter dialog based on existing states
|
1823
1941
|
|
1824
|
-
var
|
1825
|
-
var
|
1826
|
-
var selectedItems = ctx ? ctx.selectedItems : null;
|
1942
|
+
var condition2D = null;
|
1943
|
+
var filterMode = ""; // default
|
1827
1944
|
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1945
|
+
var filterFuncs = null;
|
1946
|
+
var exp = colSettings.expression;
|
1947
|
+
|
1948
|
+
if (exp) {
|
1949
|
+
if (Array.isArray(exp)) {
|
1950
|
+
if (exp.length) {
|
1951
|
+
condition2D = Array.isArray(exp[0]) ? exp : [exp]; // Guaranteed condition2D to be a 2D array
|
1952
|
+
|
1953
|
+
filterMode = "advanced";
|
1954
|
+
}
|
1955
|
+
} else if (typeof exp === "function" || typeof exp === "string" || _typeof(exp) === "object") {
|
1956
|
+
if (cfo._filters && cfo._filters.length) {
|
1957
|
+
filterFuncs = cfo._filters;
|
1958
|
+
}
|
1959
|
+
}
|
1832
1960
|
}
|
1833
1961
|
|
1834
|
-
var
|
1962
|
+
var selectedItems = {};
|
1963
|
+
var uniqueValues = cfo.uniqueValues = this.getUniqueValues(field, this._getFormatter(colIndex), "", rawDataAccessor, formattedDataAccessor, filterFuncs, selectedItems);
|
1835
1964
|
var keys = Object.keys(uniqueValues);
|
1836
1965
|
|
1837
1966
|
if (sortLogic) {
|
@@ -1862,8 +1991,8 @@ RowFilteringPlugin.prototype.openDialog = function (colIndex, runtimeDialogOptio
|
|
1862
1991
|
this._filterDialog._colIndex = colIndex;
|
1863
1992
|
this._filterDialog.data = items; // TODO: Move all settings to configuration object
|
1864
1993
|
|
1865
|
-
this._filterDialog.filterMode =
|
1866
|
-
this._filterDialog.conditions =
|
1994
|
+
this._filterDialog.filterMode = filterMode;
|
1995
|
+
this._filterDialog.conditions = condition2D;
|
1867
1996
|
|
1868
1997
|
this._filterDialog.show();
|
1869
1998
|
};
|
@@ -2059,14 +2188,6 @@ RowFilteringPlugin.prototype._onDialogFilterChanged = function (e) {
|
|
2059
2188
|
}
|
2060
2189
|
|
2061
2190
|
if (atLeastOne) {
|
2062
|
-
if (!ctx) {
|
2063
|
-
ctx = {};
|
2064
|
-
}
|
2065
|
-
|
2066
|
-
if (ctx) {
|
2067
|
-
ctx["selectedItems"] = selectedItems; // For restore item in the dialog
|
2068
|
-
}
|
2069
|
-
|
2070
2191
|
this.addColumnFilter(colIndex, itemMap, ctx);
|
2071
2192
|
}
|
2072
2193
|
|