Cell with filter type SELECT not matching by EXACT condition
Hi,
I've noticed that when you change columnDefs of a grid after they were initially created (in order to dynamically populate selectOptions of a cell that has filter type set to uiGridConstants.filter.SELECT) filter's condition will not be applied - grid will "guess" and set condition to CONTAINS.
Example scenario (like in provided plunker):
- define columnDefs
- fetch info about columns that has to be filtered as a uiGridConstants.filter.SELECT` (from a service or so)
- update column definition of a desired columns (set
cellFilterand definefilterobject) 3.1. eg. defineselectOptionsto have values 1, 2, 12 - update columnDefs by calling
$scope.gridOptions.columnDefs = angular.copy($scope.gridOptions.columnDefs); - load grid data
Result - when you try to filter by either 1 or 2, results with values {1, 12} and {2, 12} will appear among visible rows.
Note - specifying condition: uiGridConstants.filter.EXACT does not work (as stated above), but doing something like $scope.gridApi.grid.columns[columnIndex].filters[0].condition = uiGridConstants.filter.EXACT; will do the job, but I find it hacky.
Shouldn't cell of type uiGridConstants.filter.SELECT always be filtered with condition se to uiGridConstants.filter.EXACT ?
+1 This should be the expected behavior for select filters.
Thanks for this workaround:
$scope.gridApi.grid.columns[columnIndex].filters[0].condition = uiGridConstants.filter.EXACT;
saved me a lot of time!
Hi apodznoev,
$scope.gridApi.grid.columns[columnIndex].filters[0].condition = uiGridConstants.filter.EXACT;
where to exactly put this code, I'm sorry if the question is too stupid, I'm new to this technology, thanks in advance
why is this closed? Did it get solved? I'm running into this (version 3.2.1) and I'm not sure wether I should upgrade.
I'm confused now. I fixed this for me by adding the condition line in my column definition
{ field: 'art.id',
displayName: 'Art',
width: '70',
enableFiltering: true,
filter: {
type: uiGridConstants.filter.SELECT,
condition: uiGridConstants.filter.EXACT,
selectOptions: this.BeitragsArten
},
cellTemplate: '<div class="ui-grid-cell-contents">{{ row.entity.art.name }}</div>',
enableCellEdit: false,
},