我正在使用AngularJS的ngGrid模塊來顯示一些分頁數據。我希望能夠搜索多個列,但使用OR搜索。ngGrid多列過濾
可以說我有一個包含以下標題的列:Id,Name,Description。當我搜索時,我想返回Id或name或description包含搜索詞的所有行。
$scope.filterUpdated = function() {
$scope.gridOptions.filterOptions.filterText = 'id:' + $scope.filterText + ';name:' + $scope.filterText + ';description:' + $scope.filterText;
};
然而,這似乎做的:
$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
}
};
我已經使用默認的搜索框,並使用綁定到$ scope.filterText外部輸入對話框來定義自定義過濾器,例如嘗試並在所有列上。是否有可能實現我想要使用ngGrid模塊?
由於提前,
克里斯
我是AngularJS的新手,但通過johnlindquist/eggheadio/www.egghead.io瀏覽過所有視頻,我想這[ngfilter](http://www.egghead.io/video/bLohP9mh8ks)視頻回答你的題。他開始解釋你如何在3點左右使用不同的搜索過濾器;從搜索所有列開始,然後轉到特定列。 – Pixic
可能是這個討論可以幫助你。 [ng-grid filter per column](https://groups.google.com/forum/#!topic/angular/aC24cVln4Vw) – darwinbaisa
是的,您可以藉助網格配置中的內部過濾選項來實現通過列進行過濾。我很快就會把這個笨蛋放到它上面,回答 – orif