Search code examples
javascriptangularjsangular-ui-gridng-grid

modify grid-data for external filter in ng-grid angularJS


I have to modify data of grid based on external generic filter for data grid. I have searched and find out 2 ways to do so,

  1. After changing grid data according to filter, use $scope.gridApi.core.notifydatachange(uiGridConstants.dataChange.ALL)

  2. add $scope.gridApi.grid.registerRowsProcessor( $scope.singleFilter, 200 ); in $scope.gridOptions.onRegisterApi and then inside $scope.singleFilter function change visibility of data according to filter.

Is it possible to filter data according to external filter and column filter together?

If YES, I want to know which method will go very well with column filtering?


Solution

  • It is good idea to modify data for filter using $scope.gridApi.core.notifydatachange(uiGridConstants.dataChange.ALL) function. As $scope.gridApi.grid.registerRowsProcessor() is used by ng-grid internally for single column filter. And hence if we try to modify it, By default functionality of column filter will behave un-expectedly.