2017-08-28 12 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被識別爲:-) –