ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

filter search box returns prematurely when cell contains an object

Open geoffhardy opened this issue 13 years ago • 3 comments

I have an app where I put objects in each row for a particular column. When I type into the search box, the filter function returns prematurely when it can't find a match in the sub-fields of that object. The line of code is here:

https://github.com/angular-ui/ng-grid/blob/8017eee035ac21ce9989eb26ea5dc6c13b9553cd/build/ng-grid.debug.js#L2487


The snipped is here:

var pVal = item[prop];
if(typeof pVal === 'object'){
    return searchEntireRow(condition, pVal, c); // <<---
} else { /* */ }

I think line marked with // <<--- should be replaced with:

if (searchEntireRow(condition, pVal, c)) {
    return true;
}

That way, if the recursive call finds a match it short circuits, but if it doesn't it continues to examine the other columns. I tried it in my local copy and it appears to do the right thing.

Geoff

geoffhardy avatar Jul 31 '13 21:07 geoffhardy

I'll back this issue. My dataset contains nulls for certain values which breaks the filtering function for me. I dynamically have to reassign empty strings to all null values which is just ugly IMO. Any chance this can get fixed for 2.0.8 or 3?

dustinsgoodman avatar Jan 22 '14 23:01 dustinsgoodman

@geoffhardy - Thanks, that worked for me as well.

mikekhristo avatar Apr 18 '14 16:04 mikekhristo

Hi,

I want to filter the rows in a ng-grid table which has a column with null value. what should be my textString for the same ?

$scope.filterOptions = { filterText: "" };

$scope.gridOptions = { data: 'ctrl.titles', filterOptions: $scope.filterOptions }

$scope.filterOptions.filterText = ":^null";

I am not able to get the rows which has null for a certain field.

Thanks in advance for helping out with this issue.

csgopala avatar Sep 30 '14 18:09 csgopala