Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular UI-Grid filtering by strict match

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.

like image 284
user3599828 Avatar asked Dec 24 '22 16:12

user3599828


2 Answers

Try this

{
        field: 'email',
        filter: {
          condition: uiGridConstants.filter.EXACT,
          placeholder: 'your email'
        } 
      }
like image 56
Qi Tang Avatar answered Dec 29 '22 08:12

Qi Tang


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;             
          }
    }    
}
like image 24
Wahap Avatar answered Dec 29 '22 08:12

Wahap