我正在使用AngularJS的ngGrid模块来显示一些分页数据.我希望能够搜索多个列,但是使用OR搜索.
假设我有一个包含以下标题的列:Id,Name,Description.当我搜索时,我想返回Id或名称或描述包含搜索词的所有行.
$scope.pagingOptions = {
pageSizes: [20, 50, 100],
pageSize: 20,
totalServerItems: 0,
currentPage: 1
};
$scope.gridOptions =
{
data: 'myData',
columnDefs: [
{ field: 'id', displayName: 'Id' },
{ field: 'name', displayName: 'Name' },
{ field: 'description', displayName: 'Description' },
{ displayName: 'Actions', cellTemplate: '<input type="button" data-ng-click="doSomething(row.entity)" value="Do Something" />'}],
enablePaging: true,
showFooter: true,
showFilter: true,
pagingOptions: $scope.pagingOptions,
filterOptions: {
filterText: "",
useExternalFilter: false
}
};
Run Code Online (Sandbox Code Playgroud)
我尝试使用默认搜索框,并使用绑定到$ scope.filterText的外部输入框来定义自定义过滤器,例如:
$scope.filterUpdated = function () {
$scope.gridOptions.filterOptions.filterText = 'id:' + $scope.filterText + …Run Code Online (Sandbox Code Playgroud)