freedom freedom - 9 months ago 202
AngularJS Question

dynamic columnDef in ng-Grid

I want to assign ng-grid columns name dynamically after value returned from database, but issue is that it get initialized before data return from ajax, and i am not able to recall gridOption so it showing balnk, so please help me that how can we construct a column name by ajax return value.

$scope.gridOptions =
data: 'data.Values',
{ field: "ID", displayName: "Record Id" },
{ field: "Value", displayName: $scope.ColumnName, cellFilter: cellfilterType },


coming from below line...

RecordService.getRecords().then(function (data) {
$scope.ColumnName= data.something;



Thanks Max for your help, I have done this with of help columnDef as below

Step 1:

$scope.colDef = [];

Step 2:

RecordService.getRecords().then(function (data){      

Step 3:

$scope.gridOptions = {   
    data: 'data.UdiValues',  
    filterOptions: $scope.filterOptions