I want to do an either or kind of query on ng-grid where it searches both columns with the same filter text.
I've figured out how to filter on a per column basis, but what I would like to do is filter on two columns with the same input.
var searchQuery = 'college:' + collegeText + ";" + 'curriculumName:' + $scope.filterText + 'department:' + $scope.filterText + ';';
Doesn't seem to work. I have to remove either department or curriculumName to get a result. Apparently, it thinks it needs to find it in both columns to return a result.
There is an example on this resource. Checkout the repo and load the page in the browser.
Basically, you can rely on the filterChanged event. Assuming you have a search bar as follows in the HTML:
<input type="text" ng-model="filteringText" placeholder="Search..." class="search-query"/>
The JavaScript part will look like:
// Initialize
$scope.filteringText = '';
$scope.filterOptions = {
filterText: 'filteringText',
useExternalFilter: false
};
// Configure ng-grid.
$scope.gridOptions = {
...
filterOptions: $scope.filterOptions,
...
};
$scope.$on('filterChanged', function (evt, text) {
console.log(text);
$scope.filteringText = text;
});