Search code examples
angularjsangular-ui-gridui-grid

Angular ui-grid TypeError: Cannot read property 'SELECT' of undefined


I've been struggling with this error for a while now, I am trying to create a drop down list for the filter function on ui-grid but I seem to get a TypeError: Cannot read property 'SELECT' of undefined, the error occurs on line where type: uiGridConstants.filter.SELECT is stated.

Here is my code:


var columnDefs = [
            {name: "Updated by", field: "updatedBy", enableHiding: false, enableSorting:true, width: "*",enableFiltering: false},
            {name: "Date Updated", field: "updatedDateTime", enableHiding: false, enableSorting:true,width: "*",enableFiltering: false},
            {name: "Action Group", field: "actionGroup", enableHiding: false,enableSorting: true,
                filter: {
                    type: uiGridConstants.filter.SELECT,
                    selectOptions: groupTypes
                }
            },
            {name: "Action Performed", field: "actionPerformed", enableHiding: false, width: "75%"}
        ];

I have tried following the guide on the tutorial page of ui-grid but keep running into this error Thanks


Solution

  • Found the cause of the problem, basically I was passing uiGridConstants in the wrong order to the function, Eg:

    What it was:

    XXX.controller('XXXController', ['$location', '$scope','uiGridConstants', '$route', '$http', function ($location, $scope, $route, $http,uiGridConstants)
    

    What it should be:

    XXX.controller('XXXController', ['$location', '$scope','uiGridConstants', '$route', '$http', function ($location, $scope,uiGridConstants, $route, $http)
    

    I know this is a really stupid mistake, but hopefully someone will someday see this and not waste time like I did