简体   繁体   English

如何通过下拉值过滤NG-Grid

[英]How to filter the NG-Grid by dropdown values

I have a drop down menu which get populated from Nggrid Column. 我有一个下拉菜单,该菜单从Nggrid Column填充。 The dropdown is a separate control. 下拉菜单是一个单独的控件。

I want to filter the NG-grid based on the value selected from drop down value. 我想基于从下拉值中选择的值来过滤NG网格。 How do I do this? 我该怎么做呢?

you could add an ng-change to your select like this: 您可以像这样将ng-change添加到您的选择中:

select(ng-model="search", ng-options="data in datas", ng-change='myfilter()')

and in your controller: 并在您的控制器中:

$scope.myfilter = function() {
   $scope.datas = $filter('filter')($scope.datas, {data.YourField: $scope.search});
    // or:
    // $scope.datas = $scope.datas.filter(function(data) {
    //    return data.YourField == search || data.YourOther == search;
    // }
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM