Search code examples
ag-gridag-grid-angular

Unable to access cellvalue when using external filter ag-grid with angularjs


I'm using an external filter in ag-grid which is supposed to filter the records based on a select value dropdown which has values corresponding to a specific field in the grid.

And I'm unable to access the value of the field using node.data.fieldName as mentioned in the documentation here.

Below is what I'm doing:

function isExternalFilterPresent() {

                    return $scope.filterval.ReleaseType!='All' && $scope.filterval.ReleaseType!='';
                }
                function doesExternalFilterPass(){
                    console.log('$scope.filterval.ReleaseType : ' ,$scope.filterval.ReleaseType);
                    if($scope.filterval.ReleaseType == 'A'){return node.data.ReleaseType = 'A';}
                    if($scope.filterval.ReleaseType == 'B'){}
                    if($scope.filterval.ReleaseType == 'C'){}
                    if($scope.filterval.ReleaseType == 'D'){}
                    if($scope.filterval.ReleaseType == 'D'){}
                }

It throws an error : node is not defined When I try using just data.fieldName it says 'data is not defined'

Can someone please help me understand how I can access the value of the specific field here.


Solution

  • You need to provide node as an argument to the function. calls this function with appropriate argument node.

    Link: Example External filter

         function doesExternalFilterPass(node) {   // <- node as argument
           console.log('$scope.filterval.ReleaseType : ' ,$scope.filterval.ReleaseType);
           if($scope.filterval.ReleaseType == 'A'){return node.data.ReleaseType = 'A';}
               if($scope.filterval.ReleaseType == 'B'){}
                 if($scope.filterval.ReleaseType == 'C'){}
                 if($scope.filterval.ReleaseType == 'D'){}
                 if($scope.filterval.ReleaseType == 'D'){}
           }