How to filter the NG-Grid by dropdown values

為{幸葍}努か 提交于 2019-12-24 21:26:52

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/22528007/how-to-filter-the-ng-grid-by-dropdown-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!