2017-08-28 85 views
0

我试图让行只能选择$treeLevel。 控制台返回ReferenceError: uiGridConstants is not defined。我不得不承认,我不完全理解uiGridConstants代表什么。enableSelection和uiGridConstants

这里是我的代码:

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); 

回答

2

uiGridConstants是模块和你一样有你注入$scope注入它的依赖到控制器中。

样品:

app.controller('SurveyReportController', ['$scope', 'uiGridConstants', 
    function($scope, uiGridConstants) { 

     \\ your angular controller code here 

    } 
]); 
+0

谢谢!我的代码不起作用,但uiGridConstants被识别为:-) –