Custom Filter is broken
http://ui-grid.info/docs/#/tutorial/103_filtering
Steps to reproduce
- Put some values in the age column filter (both greater than and smaller than)
- Delete the contents of the filter
- Put some filters again.
When I do that it seems to work fine. What behaviour do you get when you put the filters back in?
When I put the filter back in the grid shows nothing. Try using backspace instead of the x button.
I followed your steps and experienced the same problem.
Making a small change to searchColumn function fixes the issue
rowSearcher.searchColumn = function searchColumn(grid, row, column, filters) {
if (grid.options.useExternalFiltering) {
return true;
}
var filtersLength = filters.length;
for (var i = 0; i < filtersLength; i++) {
var filter = filters[i];
if ( !gridUtil.isNullOrUndefined(filter.term) && filter.term !== '' || filter.noTerm ){
var ret = rowSearcher.runColumnFilter(grid, row, column, filter);
if (!ret) {
return false;
}
}
}
return true;
};
The issue is only for columns with multiple filters(for age column it is greater than and less than). runColumnFilter should not get called with empty filters.
If you think you've solved the issue feel free to make a pull request and we'll review it.
If anyone looking for a temporary fix
var uiGridCustom = {
filter: {
GREATER_THAN: function (searchTerm, cellValue) {
if (searchTerm == '')
return true;
else return cellValue > searchTerm;
},
LESS_THAN: function (searchTerm, cellValue) {
if (searchTerm == '')
return true;
else return cellValue < searchTerm;
}
}
};