简体   繁体   中英

How to filter the NG-Grid by dropdown values

I have a drop down menu which get populated from Nggrid Column. The dropdown is a separate control.

I want to filter the NG-grid based on the value selected from drop down value. How do I do this?

you could add an ng-change to your select like this:

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;
    // }
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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