admin管理员组文章数量:1314568
I'm creating a table with Angular UI-Grid and I wanted to filter the table contents by a strict match. By default "Car" input will match with "Carol" but I want UI-Grid's filtering to only match if the input is equal to a table entry.
I'm creating a table with Angular UI-Grid and I wanted to filter the table contents by a strict match. By default "Car" input will match with "Carol" but I want UI-Grid's filtering to only match if the input is equal to a table entry.
Share Improve this question asked Jul 28, 2015 at 17:04 user3599828user3599828 3318 silver badges14 bronze badges3 Answers
Reset to default 8Try this
{
field: 'email',
filter: {
condition: uiGridConstants.filter.EXACT,
placeholder: 'your email'
}
}
Trying uiGridConstants.filter.EXACT causes fetching also CAR 1, CAR 2.
If you want to fetch "CAR" only, excluding "CAR 1" and "CAR 2", using a function would be useful:
{ field: 'name', width :'150', filter: {
condition: function(searchTerm, cellValue) {
if (searchTerm === cellValue)
return -1;
else
return 0;
}
}
}
Make a filter method. Instead of having ng-repeat="x in items|filter:filterVariable"
use a filter method. In your controller code put:
var myFilter = function(x){
return x == $scope.filterVariable;
}
and the ng-repeat
would look like:
ng-repeat="x in items | filter:myFilter"
本文标签: javascriptAngular UIGrid filtering by strict matchStack Overflow
版权声明:本文标题:javascript - Angular UI-Grid filtering by strict match - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741966546a2407580.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论