How to filter my data? (ng-grid)

后端 未结 3 921
夕颜
夕颜 2020-12-23 14:31

I think this is most likely very simple but I cannot find any clear documentation on how to add a filter outside of the \'filterText\' that is shown on their website. What I

3条回答
  •  悲&欢浪女
    2020-12-23 15:12

    You can use angular to bind to the filterOptions.filterText variable. There's a plunker here to demonstrate: http://plnkr.co/edit/PHdBhF?p=preview

    I'll post the same code below:

        // main.js
        var app = angular.module('myApp', ['ngGrid']);
        app.controller('MyCtrl', function($scope) {
          $scope.filterOptions = {
            filterText: ''
          };
    
          $scope.myData = [{name: "Moroni", age: 50},
                           {name: "Tiancum", age: 43},
                           {name: "Jacob", age: 27},
                           {name: "Nephi", age: 29},
                           {name: "Enos", age: 34}];
    
          $scope.gridOptions = {
            data: 'myData',
            filterOptions: $scope.filterOptions
          };
        });
    

    The above should be about identical to the plunkers on the docs page.

        
        
            
                
                Custom Plunker  
                
                
                
                
                
                
                
                
            
            
              Filter:
              

    Notice ng-model="filterOptions.filterText" on the . That's all it takes!

提交回复
热议问题