Search code examples
angularjsangular-ui-gridui-grid

enableSelection and uiGridConstants


I'm trying to get rows selectable only with a certain $treeLevel. The console returned a ReferenceError: uiGridConstants is not defined.

I have to admit that I don't fully understand what uiGridConstants stands for.

Here is my code:

onRegisterApi: function (gridApi) {

        this.gridApiBatches = gridApi;
        console.info(gridApi);

        gridApi.grid.options.enableSelection = function (row) {
            if (row.entity.$treeLevel != 3) {
                return false;
            } else {
                return true;
            }
        };
        gridApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS);

Solution

  • uiGridConstants is module and you have to inject it as dependency into your controller just like you inject $scope.

    Sample:

    app.controller('SurveyReportController', ['$scope', 'uiGridConstants',
        function($scope, uiGridConstants) {
    
            \\ your angular controller code here
    
        }
    ]);