@refinitiv-ui/efx-grid 6.0.68 → 6.0.70

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.
@@ -61,7 +61,7 @@ The expression can take various forms:<br>
61
61
  */
62
62
 
63
63
  /** @typedef {Object} RowFilteringPlugin~FilterExpression
64
- * @description FilterExpression contains all data used for saving and restoring filter in a column
64
+ * @description Deprecated. FilterExpression contains all data used for saving and restoring filter in a column
65
65
  * @property {string} field
66
66
  * @property {RowFilteringPlugin~Expression} expression Expression representing filter function
67
67
  * @property {*} context Context object contains context/states given by user
@@ -307,6 +307,8 @@ RowFilteringPlugin.prototype.unload = function (host) {
307
307
  host.unlisten("columnRemoved", this._onColumnRemoved);
308
308
 
309
309
  if (!this._hosts.length) {
310
+ this._hasPendingFilter = false;
311
+
310
312
  if (this._filterDialog) {
311
313
  this._filterDialog.hide(); // Remove the dialog from document
312
314
 
@@ -335,6 +337,34 @@ RowFilteringPlugin.prototype._afterInit = function () {
335
337
  setTimeout(this._onPreLoadedDialog, 10);
336
338
  }
337
339
  }
340
+
341
+ this._applyPendingFilter();
342
+ };
343
+ /** @private
344
+ */
345
+
346
+
347
+ RowFilteringPlugin.prototype._applyPendingFilter = function () {
348
+ if (!this._initializedGrid) {
349
+ return;
350
+ }
351
+
352
+ if (!this._hasPendingFilter) {
353
+ return;
354
+ }
355
+
356
+ this._hasPendingFilter = false;
357
+ var colCount = this.getColumnCount();
358
+
359
+ for (var c = 0; c < colCount; ++c) {
360
+ var colSettings = this._getUserColumnSettings(c);
361
+
362
+ if (colSettings.expression) {
363
+ this.addColumnFilter(c, colSettings.expression, colSettings.filterState);
364
+ } else {
365
+ this._removeColumnFilters(c);
366
+ }
367
+ }
338
368
  };
339
369
  /** @private
340
370
  */
@@ -424,6 +454,8 @@ RowFilteringPlugin.prototype.config = function (options) {
424
454
 
425
455
  this._setColumnOptions(i, column);
426
456
  }
457
+
458
+ this._applyPendingFilter();
427
459
  };
428
460
  /** @public
429
461
  * @param {Object=} gridOptions
@@ -448,22 +480,20 @@ RowFilteringPlugin.prototype.getConfigObject = function (gridOptions) {
448
480
  column = columns[i] = {};
449
481
  }
450
482
 
451
- var cfo = this._getColumnFilterOption(i);
483
+ var colSettings = this._getUserColumnSettings(i);
452
484
 
453
- if (cfo) {
454
- var exp = cfo._expressions[0];
485
+ var exp = colSettings.expression;
455
486
 
456
- if (exp && typeof exp !== "function") {
457
- // TODO: Accept function type
458
- column.filter = exp; // This could be string, array, or object
459
- }
487
+ if (exp && typeof exp !== "function") {
488
+ // TODO: Accept function type
489
+ column.filter = exp; // This could be string, array, or object
490
+ }
460
491
 
461
- var ctx = cfo._context[0];
492
+ var ctx = colSettings.filterState;
462
493
 
463
- if (ctx != null) {
464
- if (_typeof(ctx) !== "object" || !ctx._autoGenerated) {
465
- column.filterState = ctx;
466
- }
494
+ if (ctx != null) {
495
+ if (_typeof(ctx) !== "object" || !ctx._autoGenerated) {
496
+ column.filterState = ctx;
467
497
  }
468
498
  }
469
499
  }
@@ -655,7 +685,10 @@ RowFilteringPlugin.prototype.addColumnFilter = function (colIndex, exp, ctx) {
655
685
  func =
656
686
  /** @type{Function} */
657
687
  exp;
658
- exp = ctx && typeof ctx === "string" ? ctx : null; // for saving. TODO: Support saving for function type
688
+
689
+ if (ctx && typeof ctx === "string") {
690
+ exp = ctx;
691
+ }
659
692
  } else {
660
693
  func = this._parseFilter(exp, colIndex, ctx);
661
694
  }
@@ -664,6 +697,16 @@ RowFilteringPlugin.prototype.addColumnFilter = function (colIndex, exp, ctx) {
664
697
  return false;
665
698
  }
666
699
 
700
+ if (colIndex < 0 || colIndex >= this.getColumnCount()) {
701
+ return false;
702
+ }
703
+
704
+ var colSettings = this._getUserColumnSettings(colIndex);
705
+
706
+ colSettings.expression = exp; // WARNING: Only the last expression are saved (previous one is overwritten)
707
+
708
+ colSettings.filterState = ctx;
709
+
667
710
  if (ctx == null) {
668
711
  ctx = {
669
712
  "_autoGenerated": true
@@ -712,10 +755,28 @@ RowFilteringPlugin.prototype.addColumnFilter = function (colIndex, exp, ctx) {
712
755
  * @param {(Object|string)=} ctx Context object that will be passed as the third parameter for the filter logic
713
756
  * @return {boolean} True If there is any change
714
757
  * @fires RowFilteringPlugin#filterChanged
758
+ * @example
759
+ * extension.setColumnFilter(colIndex1,
760
+ * [["GT", 0]]
761
+ * );
762
+ * extension.setColumnFilter(colIndex2,
763
+ * "filter": "[PCTCHNG] > 0"
764
+ * );
765
+ * extension.setColumnFilter(colIndex3,
766
+ * function(rowData) {
767
+ * return rowData["PCTCHNG"] > 0;
768
+ * }
769
+ * );
715
770
  */
716
771
 
717
772
 
718
773
  RowFilteringPlugin.prototype.setColumnFilter = function (colIndex, exp, ctx) {
774
+ var curExp = this._getColumnExpression(colIndex);
775
+
776
+ if (curExp === exp) {
777
+ return false;
778
+ }
779
+
719
780
  var removed = this._removeColumnFilters(colIndex);
720
781
 
721
782
  var added = this.addColumnFilter(colIndex, exp, ctx);
@@ -726,71 +787,88 @@ RowFilteringPlugin.prototype.setColumnFilter = function (colIndex, exp, ctx) {
726
787
 
727
788
  return removed || added;
728
789
  };
790
+ /** @private
791
+ * @param {number} colIndex
792
+ * @return {RowFilteringPlugin~Expression}
793
+ */
794
+
795
+
796
+ RowFilteringPlugin.prototype._getColumnExpression = function (colIndex) {
797
+ var colSettings = this._getUserColumnSettings(colIndex);
798
+
799
+ return colSettings.expression || null;
800
+ };
729
801
  /** Set data to colData["rowFiltering"]
730
802
  * @private
731
803
  * @param {number} colIndex
732
- * @param {RowFilteringPlugin~ColumnOptions} columnOptions
804
+ * @param {RowFilteringPlugin~ColumnOptions} userObj
733
805
  * @example
734
- * var colDef = {
735
- * "filter": "gt♦0♣"
806
+ * var colDef1 = {
807
+ * "field": "PCTCHNG",
808
+ * "filter": [["GT", 0]]
736
809
  * };
737
810
  * var colDef2 = {
738
811
  * "filter": "[PCTCHNG] > 0"
739
812
  * };
740
813
  * var colDef3 = {
741
- * "filter": function() { }
814
+ * "filter": function(rowData) {
815
+ * return rowData["PCTCHNG"] > 0;
816
+ * }
742
817
  * };
743
818
  */
744
819
 
745
820
 
746
- RowFilteringPlugin.prototype._setColumnOptions = function (colIndex, columnOptions) {
747
- var colOptions = this._newExtColumnOptions(colIndex);
821
+ RowFilteringPlugin.prototype._setColumnOptions = function (colIndex, userObj) {
822
+ var colSettings = this._getUserColumnSettings(colIndex);
748
823
 
749
- var filterIcon = columnOptions["filterIcon"];
750
- var fieldDataType = columnOptions["fieldDataType"] || columnOptions["dataType"]; // TODO: This should not be set here, should retreive data type from Composite/Realtime Grid
824
+ var filterIcon = userObj["filterIcon"]; // TODO: This should not be set here, should retreive data type from Composite/Realtime Grid
825
+
826
+ var fieldDataType = userObj["fieldDataType"] || userObj["dataType"];
751
827
 
752
828
  if (fieldDataType) {
753
- colOptions.fieldDataType = fieldDataType; // TODO: This should not be set here, should retreive data type from Composite/Realtime Grid
829
+ colSettings.fieldDataType = fieldDataType; // TODO: This should not be set here, should retreive data type from Composite/Realtime Grid
754
830
  }
755
831
 
756
832
  if (filterIcon != null) {
757
- colOptions.filterIcon = filterIcon;
833
+ colSettings.filterIcon = filterIcon;
758
834
  }
759
835
 
760
- var iconActivation = filterIcon == false ? "none" : this._iconActivation;
761
- var exp = columnOptions["filter"];
836
+ var exp = userObj["filter"];
762
837
 
763
- if (exp) {
764
- this.addColumnFilter(colIndex, exp, columnOptions["filterState"]);
765
- } else if (iconActivation == "always" || iconActivation == "onHover") {
766
- this._updateColumnIcon(colIndex);
838
+ if (exp != null) {
839
+ colSettings.expression = exp;
840
+ colSettings.filterState = null;
841
+ this._hasPendingFilter = true;
767
842
  }
768
- };
769
- /** @private
770
- * @param {number} colIndex
771
- * @return {Object} colData["rowFiltering"]
772
- */
773
843
 
844
+ var filterState = userObj["filterState"];
845
+
846
+ if (filterState != null) {
847
+ colSettings.filterState = filterState;
848
+ }
849
+
850
+ var iconActivation = filterIcon == false ? "none" : this._iconActivation;
774
851
 
775
- RowFilteringPlugin.prototype._getExtColumnOptions = function (colIndex) {
776
- return this._getColumnOption(colIndex, "rowFiltering");
852
+ if (iconActivation == "always" || iconActivation == "onHover") {
853
+ this._updateColumnIcon(colIndex);
854
+ }
777
855
  };
778
856
  /** @private
779
857
  * @param {number} colIndex
780
- * @return {!Object} Newly created extension column option or the existing one
858
+ * @return {!Object} colData["rowFiltering"]
781
859
  */
782
860
 
783
861
 
784
- RowFilteringPlugin.prototype._newExtColumnOptions = function (colIndex) {
785
- var colDef = this._newColumnData(colIndex);
862
+ RowFilteringPlugin.prototype._getUserColumnSettings = function (colIndex) {
863
+ var colData = this._newColumnData(colIndex);
786
864
 
787
- var colExtOptions = colDef["rowFiltering"];
865
+ var colSettings = colData["rowFiltering"];
788
866
 
789
- if (!colExtOptions) {
790
- colExtOptions = colDef["rowFiltering"] = {};
867
+ if (!colSettings) {
868
+ colSettings = colData["rowFiltering"] = {};
791
869
  }
792
870
 
793
- return colExtOptions;
871
+ return colSettings;
794
872
  };
795
873
  /** @private
796
874
  * @param {number} colIndex
@@ -799,40 +877,37 @@ RowFilteringPlugin.prototype._newExtColumnOptions = function (colIndex) {
799
877
 
800
878
 
801
879
  RowFilteringPlugin.prototype._getColumnFilterOption = function (colIndex) {
802
- var colOptions = this._getExtColumnOptions(colIndex);
880
+ var colSettings = this._getUserColumnSettings(colIndex);
803
881
 
804
- if (colOptions) {
805
- return colOptions["filterOption"] || null;
882
+ if (colSettings) {
883
+ return colSettings["filterOption"] || null;
806
884
  } else {
807
885
  return null;
808
886
  }
809
887
  };
810
- /** Set data to colData["rowFiltering"]["filterOption"]
888
+ /** Remove colData["rowFiltering"]["filterOption"]
811
889
  * @private
812
890
  * @param {number} colIndex
813
- * @param {Object} filterOption
814
891
  */
815
892
 
816
893
 
817
- RowFilteringPlugin.prototype._setColumnFilterOption = function (colIndex, filterOption) {
818
- var colOptions = this._newExtColumnOptions(colIndex);
819
-
820
- if (filterOption) {
821
- colOptions["filterOption"] = filterOption;
822
- } else {
823
- var cfo = colOptions["filterOption"];
894
+ RowFilteringPlugin.prototype._removeActiveFilterStates = function (colIndex) {
895
+ var colSettings = this._getUserColumnSettings(colIndex);
824
896
 
825
- if (cfo) {
826
- colOptions["filterOption"] = null;
897
+ colSettings.expression = null;
898
+ colSettings.filterState = null;
899
+ var cfo = colSettings["filterOption"];
827
900
 
828
- if (cfo._filters.length) {
829
- this._dispatch("filterChanged", {
830
- "filterType": "column",
831
- "changeType": "remove",
832
- "colIndex": colIndex,
833
- "field": this._getField(colIndex)
834
- });
835
- }
901
+ if (cfo) {
902
+ colSettings["filterOption"] = null;
903
+
904
+ if (cfo._filters.length) {
905
+ this._dispatch("filterChanged", {
906
+ "filterType": "column",
907
+ "changeType": "remove",
908
+ "colIndex": colIndex,
909
+ "field": this._getField(colIndex)
910
+ });
836
911
  }
837
912
  }
838
913
  };
@@ -851,7 +926,9 @@ RowFilteringPlugin.prototype._initColumnFilterOption = function (colIndex) {
851
926
  cfo._expressions = [];
852
927
  cfo._context = [];
853
928
 
854
- this._setColumnFilterOption(colIndex, cfo);
929
+ var colSettings = this._getUserColumnSettings(colIndex);
930
+
931
+ colSettings["filterOption"] = cfo;
855
932
  }
856
933
 
857
934
  return cfo;
@@ -907,6 +984,7 @@ RowFilteringPlugin.prototype.removeFilter = function (funcRef) {
907
984
  * @public
908
985
  * @param {number} colIndex
909
986
  * @return {boolean} True if there is any change
987
+ * @fires RowFilteringPlugin#filterChanged
910
988
  */
911
989
 
912
990
 
@@ -927,6 +1005,7 @@ RowFilteringPlugin.prototype.removeColumnFilters = function (colIndex) {
927
1005
  /** @private
928
1006
  * @param {number} colIndex
929
1007
  * @return {boolean} True if there is any change
1008
+ * @fires RowFilteringPlugin#filterChanged
930
1009
  */
931
1010
 
932
1011
 
@@ -940,7 +1019,7 @@ RowFilteringPlugin.prototype._removeColumnFilters = function (colIndex) {
940
1019
  this._columnFilters.splice(funcIndex, 1);
941
1020
  }
942
1021
 
943
- this._setColumnFilterOption(colIndex, null); // filterChanged fired
1022
+ this._removeActiveFilterStates(colIndex); // filterChanged fired
944
1023
 
945
1024
 
946
1025
  var inputExt = this._getPlugin("FilterInputPlugin"); // TODO: Use the event instead
@@ -958,6 +1037,7 @@ RowFilteringPlugin.prototype._removeColumnFilters = function (colIndex) {
958
1037
  * @function
959
1038
  * @param {number} colIndex
960
1039
  * @return {boolean} True if there is any change
1040
+ * @fires RowFilteringPlugin#filterChanged
961
1041
  */
962
1042
 
963
1043
 
@@ -965,6 +1045,7 @@ RowFilteringPlugin.prototype.removeColumnFilter = RowFilteringPlugin.prototype.r
965
1045
  /** Remove all column filters from all columns, excluding global filters
966
1046
  * @public
967
1047
  * @return {boolean} Return true if there is any change
1048
+ * @fires RowFilteringPlugin#filterChanged
968
1049
  */
969
1050
 
970
1051
  RowFilteringPlugin.prototype.removeAllColumnFilters = function () {
@@ -976,7 +1057,7 @@ RowFilteringPlugin.prototype.removeAllColumnFilters = function () {
976
1057
  var colCount = this._getColumnCount();
977
1058
 
978
1059
  for (var i = 0; i < colCount; ++i) {
979
- this._setColumnFilterOption(i, null); // filterChanged fired
1060
+ this._removeActiveFilterStates(i); // filterChanged fired
980
1061
 
981
1062
 
982
1063
  inputExt && inputExt.updateUI(i, ""); // TODO: Use the event instead
@@ -1054,10 +1135,10 @@ RowFilteringPlugin.prototype.setRowTransform = function (func) {
1054
1135
  RowFilteringPlugin.prototype.getFilters = function () {
1055
1136
  return this._globalFilters;
1056
1137
  };
1057
- /** Return filter functions. Use getFilterExpressions for saving and loading instead of this function
1138
+ /** Returns filter functions. Use getConfigObject for saving and loading instead of this function
1058
1139
  * @public
1059
1140
  * @return {!Array.<Function>} All column filters
1060
- * @see {@link RowFilteringPlugin.getFilterExpressions}
1141
+ * @see {@link RowFilteringPlugin.getConfigObject}
1061
1142
  */
1062
1143
 
1063
1144
 
@@ -1076,21 +1157,22 @@ RowFilteringPlugin.prototype.getAllColumnFilters = function () {
1076
1157
 
1077
1158
  return filters;
1078
1159
  };
1079
- /** Get existing filter expressions for saving and restoring.
1160
+ /** Deprecated in favor of getConfigObject(). Get existing filter expressions for saving and restoring.
1080
1161
  * @public
1081
1162
  * @return {Array.<RowFilteringPlugin~FilterExpression>} Return null if there is no column filter
1082
- * @see {@link RowFilteringPlugin.setFilterExpressions}
1163
+ * @see {@link RowFilteringPlugin.getConfigObject}
1083
1164
  */
1084
1165
 
1085
1166
 
1086
1167
  RowFilteringPlugin.prototype.getFilterExpressions = function () {
1087
1168
  if (this._columnFilters.length) {
1169
+ // TODO: Provide a way to save rawDataAccessor and formattedDataAccessor
1088
1170
  return this._columnFilters.map(toFilterExpression);
1089
1171
  }
1090
1172
 
1091
1173
  return null;
1092
1174
  };
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();
1175
+ /** 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
1176
  * @public
1095
1177
  * @param {Array.<RowFilteringPlugin~FilterExpression>} filterExps
1096
1178
  */
@@ -1110,7 +1192,7 @@ RowFilteringPlugin.prototype.setFilterExpressions = function (filterExps) {
1110
1192
  var colIndex = fields.indexOf(field);
1111
1193
 
1112
1194
  if (colIndex >= 0) {
1113
- this.addColumnFilter(colIndex, filterExp.expression, filterExp.context);
1195
+ this.setColumnFilter(colIndex, filterExp.expression, filterExp.context);
1114
1196
  }
1115
1197
  }
1116
1198
  }
@@ -1349,11 +1431,13 @@ RowFilteringPlugin.prototype.refresh = function () {
1349
1431
 
1350
1432
 
1351
1433
  RowFilteringPlugin.prototype._updateColumnIcon = function (colIndex) {
1352
- var cfo = this._getColumnFilterOption(colIndex);
1434
+ var cfo = this._getColumnFilterOption(colIndex); // colData["rowFiltering"]["filterOption"]
1353
1435
 
1354
- var co = this._getExtColumnOptions(colIndex);
1355
1436
 
1356
- var iconActivation = co.filterIcon == false ? "none" : this._iconActivation;
1437
+ var colSettings = this._getUserColumnSettings(colIndex); // colData["rowFiltering"]
1438
+
1439
+
1440
+ var iconActivation = colSettings.filterIcon == false ? "none" : this._iconActivation;
1357
1441
  var hasFilter = cfo ? cfo._filters.length : 0;
1358
1442
 
1359
1443
  for (var i = this._hosts.length; --i >= 0;) {
@@ -1492,10 +1576,10 @@ RowFilteringPlugin.prototype.getColumnFilterState = function (colIndex) {
1492
1576
 
1493
1577
  return null;
1494
1578
  };
1495
- /** Get the stored user context from all columns. The column with no filter will return null value
1579
+ /** Deprecated in favor of getConfigObject(). Get the stored user context from all columns. The column with no filter will return null value
1496
1580
  * @public
1497
1581
  * @return {!Array} Array of context objects
1498
- * @see {@link RowFilteringPlugin.getFilterExpressions}
1582
+ * @see {@link RowFilteringPlugin.getConfigObject}
1499
1583
  */
1500
1584
 
1501
1585
 
@@ -1554,11 +1638,13 @@ RowFilteringPlugin.prototype._getDataTable = function (dv) {
1554
1638
  * @param {string=} fmtField A field name to be used instead of formatter for getting formatted value
1555
1639
  * @param {Function=} rawDataAccessor Data getter to retrieve raw value
1556
1640
  * @param {Function=} formattedDataAccessor Data getter to retrieve formatted value. This paramter will override formatted and fmtField parameters
1641
+ * @param {Function=} filterFuncs
1642
+ * @param {Object=} selectedItems
1557
1643
  * @return {Object} Object that maps formatted value to array of raw values
1558
1644
  */
1559
1645
 
1560
1646
 
1561
- RowFilteringPlugin.prototype.getUniqueValues = function (field, formatter, fmtField, rawDataAccessor, formattedDataAccessor) {
1647
+ RowFilteringPlugin.prototype.getUniqueValues = function (field, formatter, fmtField, rawDataAccessor, formattedDataAccessor, filterFuncs, selectedItems) {
1562
1648
  if (!field) {
1563
1649
  return null;
1564
1650
  }
@@ -1629,6 +1715,12 @@ RowFilteringPlugin.prototype.getUniqueValues = function (field, formatter, fmtFi
1629
1715
  continue;
1630
1716
  }
1631
1717
 
1718
+ if (filterFuncs) {
1719
+ if (!selectedItems[formattedVal]) {
1720
+ selectedItems[formattedVal] = RowFilteringPlugin._getFilteredValue(row, filterFuncs);
1721
+ }
1722
+ }
1723
+
1632
1724
  var rawValues = uniqueValues[formattedVal];
1633
1725
 
1634
1726
  if (rawValues) {
@@ -1668,6 +1760,23 @@ RowFilteringPlugin._createDialog = function () {
1668
1760
 
1669
1761
  return tag ? document.createElement(tag) : null;
1670
1762
  };
1763
+ /** @private
1764
+ * @function
1765
+ * @param {Object} rowData
1766
+ * @param {!Array.<Function>} filters
1767
+ * @returns {boolean}
1768
+ */
1769
+
1770
+
1771
+ RowFilteringPlugin._getFilteredValue = function (rowData, filters) {
1772
+ for (var i = filters.length; --i >= 0;) {
1773
+ if (!filters[i](rowData)) {
1774
+ return false;
1775
+ }
1776
+ }
1777
+
1778
+ return true;
1779
+ };
1671
1780
  /** @public
1672
1781
  * @param {number} colIndex
1673
1782
  * @param {RowFilteringPlugin~FilterDialogOptions=} runtimeDialogOptions
@@ -1767,13 +1876,6 @@ RowFilteringPlugin.prototype.openDialog = function (colIndex, runtimeDialogOptio
1767
1876
  this._filterDialog.setSortState(stp.getSortOrder(colIndex)); // This is for ELF v3
1768
1877
 
1769
1878
  } // 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
1879
 
1778
1880
 
1779
1881
  var colData = host.getColumnData(colIndex);
@@ -1802,36 +1904,53 @@ RowFilteringPlugin.prototype.openDialog = function (colIndex, runtimeDialogOptio
1802
1904
  };
1803
1905
  var columnDialogOptions = null;
1804
1906
 
1805
- if (colOptions) {
1806
- if (colOptions.fieldDataType) {
1807
- // TODO: Use data type from Composite Grid (getColumnDataType) or Realtime Grid (getDataType) instead
1808
- columnDialogOptions = {
1809
- fieldDataType: colOptions.fieldDataType
1810
- };
1811
- }
1907
+ var colSettings = this._getUserColumnSettings(colIndex); // colData["rowFiltering"]
1908
+
1909
+
1910
+ if (colSettings.fieldDataType) {
1911
+ // TODO: Use data type from Composite Grid (getColumnDataType) or Realtime Grid (getDataType) instead
1912
+ columnDialogOptions = {
1913
+ fieldDataType: colSettings.fieldDataType
1914
+ };
1812
1915
  }
1813
1916
 
1814
1917
  RowFilteringPlugin._overrideConfig(dialogConfig, this._dialogOptions);
1815
1918
 
1816
1919
  RowFilteringPlugin._overrideConfig(dialogConfig, columnDialogOptions);
1817
1920
 
1818
- RowFilteringPlugin._overrideConfig(dialogConfig, runtimeDialogOptions);
1921
+ RowFilteringPlugin._overrideConfig(dialogConfig, runtimeDialogOptions); // cfo is required for storing unique entries in the dialog, even though no filter is active
1922
+ // TODO: move rawDataAccessor and other settings to colSettings
1923
+
1924
+
1925
+ var cfo = this._initColumnFilterOption(colIndex); // colData["rowFiltering"]["filterOption"]
1926
+
1819
1927
 
1820
1928
  var rawDataAccessor = cfo._rawDataAccessor = dialogConfig.rawDataAccessor || null;
1821
1929
  var formattedDataAccessor = cfo._formattedDataAccessor = dialogConfig.formattedDataAccessor || null;
1822
1930
  var sortLogic = dialogConfig.sortLogic || null; // Populate data for filter dialog based on existing states
1823
1931
 
1824
- var customFilter = cfo._expressions[0] || "";
1825
- var ctx = cfo._context[0];
1826
- var selectedItems = ctx ? ctx.selectedItems : null;
1932
+ var condition2D = null;
1933
+ var filterMode = ""; // default
1827
1934
 
1828
- if (selectedItems) {
1829
- customFilter = "";
1830
- } else {
1831
- selectedItems = {};
1935
+ var filterFuncs = null;
1936
+ var exp = colSettings.expression;
1937
+
1938
+ if (exp) {
1939
+ if (Array.isArray(exp)) {
1940
+ if (exp.length) {
1941
+ condition2D = Array.isArray(exp[0]) ? exp : [exp]; // Guaranteed condition2D to be a 2D array
1942
+
1943
+ filterMode = "advanced";
1944
+ }
1945
+ } else if (typeof exp === "function" || typeof exp === "string" || _typeof(exp) === "object") {
1946
+ if (cfo._filters && cfo._filters.length) {
1947
+ filterFuncs = cfo._filters;
1948
+ }
1949
+ }
1832
1950
  }
1833
1951
 
1834
- var uniqueValues = cfo.uniqueValues = this.getUniqueValues(field, this._getFormatter(colIndex), "", rawDataAccessor, formattedDataAccessor);
1952
+ var selectedItems = {};
1953
+ var uniqueValues = cfo.uniqueValues = this.getUniqueValues(field, this._getFormatter(colIndex), "", rawDataAccessor, formattedDataAccessor, filterFuncs, selectedItems);
1835
1954
  var keys = Object.keys(uniqueValues);
1836
1955
 
1837
1956
  if (sortLogic) {
@@ -1862,8 +1981,8 @@ RowFilteringPlugin.prototype.openDialog = function (colIndex, runtimeDialogOptio
1862
1981
  this._filterDialog._colIndex = colIndex;
1863
1982
  this._filterDialog.data = items; // TODO: Move all settings to configuration object
1864
1983
 
1865
- this._filterDialog.filterMode = customFilter ? "advanced" : "";
1866
- this._filterDialog.conditions = customFilter; // WARNING: This must be 2D Array
1984
+ this._filterDialog.filterMode = filterMode;
1985
+ this._filterDialog.conditions = condition2D;
1867
1986
 
1868
1987
  this._filterDialog.show();
1869
1988
  };
@@ -2059,14 +2178,6 @@ RowFilteringPlugin.prototype._onDialogFilterChanged = function (e) {
2059
2178
  }
2060
2179
 
2061
2180
  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
2181
  this.addColumnFilter(colIndex, itemMap, ctx);
2071
2182
  }
2072
2183
 
@@ -633,16 +633,21 @@ RowSelectionPlugin.prototype._onClick = function (e) {
633
633
  * @param {Object=} mouseEvt
634
634
  */
635
635
  RowSelectionPlugin.prototype.selectByMouse = function (rowIndex, mouseEvt) {
636
- if(!mouseEvt) {
637
- mouseEvt = {};
638
- }
639
- if(rowIndex >= 0) {
640
- var grid = this._activeGrid || this._hosts[0];
641
- var cell = grid ? grid.getCell("content", 0, rowIndex) : null;
642
- mouseEvt.target = cell ? cell.getElement() : null;
643
- }
644
- this._onMouseDown(mouseEvt);
636
+ var eventObj = this._mockMouseEvent(0, rowIndex, mouseEvt);
637
+ this._onMouseDown(eventObj);
638
+ };
639
+
640
+ /** @public
641
+ * @description Select a specified row as if it were modified by a keyboard input. This is for testing purpose.
642
+ * @ignore
643
+ * @param {number|string} keyCode Use key code number or "up", "down" string
644
+ * @param {Object=} keyboardEvt
645
+ */
646
+ RowSelectionPlugin.prototype.selectByKey = function (keyCode, keyboardEvt) {
647
+ var eventObj = this._mockKeyboardEvent(keyCode, keyboardEvt);
648
+ this._onKeyDown(eventObj);
645
649
  };
650
+
646
651
  /** @private
647
652
  * @description Left click will cause single row selection <br>
648
653
  * Shift + left click will cause range selection <br>
@@ -783,29 +788,6 @@ RowSelectionPlugin.prototype._clearPendingClickIndex = function (host) {
783
788
  host && host.unlisten("mousemove", this._onMouseMove);
784
789
  };
785
790
 
786
- /** @public
787
- * @description Select a specified row as if it were modified by a keyboard input. This is for testing purpose.
788
- * @ignore
789
- * @param {number} keyCode Use -1 for arrow up. Use 1 for arrow down
790
- * @param {Object=} keyboardEvt
791
- */
792
- RowSelectionPlugin.prototype.selectByKey = function (keyCode, keyboardEvt) {
793
- if(!keyboardEvt) {
794
- keyboardEvt = {};
795
- }
796
- if(keyCode) {
797
- if(keyCode === 1) {
798
- keyboardEvt.keyCode = 40;
799
- } else if(keyCode === -1) {
800
- keyboardEvt.keyCode = 38;
801
- } else if(typeof keyCode === "number"){
802
- keyboardEvt.keyCode = keyCode;
803
- }
804
- }
805
- keyboardEvt.preventDefault = function(){};
806
- keyboardEvt.stopPropagation = function(){};
807
- this._onKeyDown(keyboardEvt);
808
- };
809
791
  /** @private
810
792
  * @param {KeyboardEvent} e
811
793
  */