From d3e5ba5a96a5973e8d815c48b8d48ed36b4cfe78 Mon Sep 17 00:00:00 2001 From: ravishivt Date: Thu, 30 Apr 2015 17:44:25 -0700 Subject: [PATCH 1/3] For SELECT filter ng-options, use track by instead of selectAs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the dropdown view when initializing the dropdown value’s "term" or when setting the "term" value programmatically such as during table restore state. --- src/templates/ui-grid/ui-grid-filter.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/ui-grid/ui-grid-filter.html b/src/templates/ui-grid/ui-grid-filter.html index 467577134f..6c58b7975d 100644 --- a/src/templates/ui-grid/ui-grid-filter.html +++ b/src/templates/ui-grid/ui-grid-filter.html @@ -8,7 +8,7 @@
- From 847c1d783c550dbec6644cbdf2e09b46b8f64452 Mon Sep 17 00:00:00 2001 From: ravishivt Date: Fri, 1 May 2015 11:38:05 -0700 Subject: [PATCH 2/3] Altered how SELECT filters compare values Since searchOption now uses "track by" instead of "selectAs", the entire searchOption object will be set as the term. This would require a custom condition function for every SELECT filter since you would need to extract the term.value before comparing to the cell value. This code extracts the .value before it does the comparison. It also uses angular.equals() to compare the SELECT filters by default instead of trying to use a starts with regex. This solves the problem of using objects instead of strings for searchOption values. --- src/js/core/services/rowSearcher.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/js/core/services/rowSearcher.js b/src/js/core/services/rowSearcher.js index 17fd11d165..bf98f2d6d3 100644 --- a/src/js/core/services/rowSearcher.js +++ b/src/js/core/services/rowSearcher.js @@ -77,6 +77,13 @@ module.service('rowSearcher', ['gridUtil', 'uiGridConstants', function (gridUtil } var term = rowSearcher.getTerm(filter); + + // A searchOption value could be an object so it is better to user angular.equals instead of a regex. + if (angular.isObject(term) && term.value && !angular.isDefined(filter.condition)) { + return function(searchTerm, cellValue) { + return angular.equals(searchTerm, cellValue); + } + } if (/\*/.test(term)) { var regexpFlags = ''; @@ -178,7 +185,8 @@ module.service('rowSearcher', ['gridUtil', 'uiGridConstants', function (gridUtil var conditionType = typeof(filter.condition); // Term to search for. - var term = filter.term; + // Exctract the term.value for selectOptions since ng-options track by returns the entire object. + var term = angular.isObject(filter.term) && filter.term.value ? filter.term.value : filter.term; // Get the column value for this row var value = grid.getCellValue(row, column); From 06720afc7463e039a77a5d8df8f0cf440cf0a223 Mon Sep 17 00:00:00 2001 From: ravishivt Date: Fri, 1 May 2015 14:20:05 -0700 Subject: [PATCH 3/3] Add missing semicolon --- src/js/core/services/rowSearcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/core/services/rowSearcher.js b/src/js/core/services/rowSearcher.js index bf98f2d6d3..d0a9f2d23b 100644 --- a/src/js/core/services/rowSearcher.js +++ b/src/js/core/services/rowSearcher.js @@ -82,7 +82,7 @@ module.service('rowSearcher', ['gridUtil', 'uiGridConstants', function (gridUtil if (angular.isObject(term) && term.value && !angular.isDefined(filter.condition)) { return function(searchTerm, cellValue) { return angular.equals(searchTerm, cellValue); - } + }; } if (/\*/.test(term)) {