angularjs – ui-grid dynamic cellFilter

angularjs – ui-grid dynamic cellFilter

This should do it for you, a small tweak that makes use of angular.copy():

var app = angular.module(app, [ui.grid]);
app.controller(MainCtrl, [$scope, $http, function($scope, $http) {
  $scope.gridOptions1 = {
    enableFiltering: true,
    columnDefs: [{
      field: age,
      cellFilter: currency
    }]
  };

  $scope.gridOptions = angular.copy($scope.gridOptions1);
  $http.get(//cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/500_complex.json)
    .success(function(data) {
      $scope.gridOptions.data = data;
    });

  $scope.updateFilter = function() {
    $scope.gridOptions1.columnDefs[0].cellFilter = number;
    $scope.gridOptions = angular.copy($scope.gridOptions1);
  };
}]);

Heres a working Plunker, http://plnkr.co/edit/p3pBKvFH3pJcpps02sN9?p=preview.

Let me know if you need anything else. Happy to help further.

angularjs – ui-grid dynamic cellFilter

Leave a Reply

Your email address will not be published.