我想在ng-grid上做一个查询,它搜索具有相同过滤文本的两列。
我已经知道如何按列进行过滤,但是我想做的是对具有相同输入的两列进行过滤。
var searchQuery = 'college:' + collegeText + ";"+ 'curriculumName:' + $scope。filterText + 'department:' + $scope。
似乎不起作用。我必须删除部门或课程名称才能得到结果。显然,它认为需要在两列中都找到它才能返回结果。
关于这个资源有一个示例。签出repo并在浏览器中加载页面。
基本上,您可以依赖filterChanged
事件。假设在HTML中有如下的搜索栏:
<input type="text" ng-model="filteringText" placeholder="Search..." class="search-query"/>
JavaScript部分看起来像:
// 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;
});