I need that in the cell of one of the columns (by condition if IsEnum = true) be select dropdown.

I do this:

$scope.gridOptions.data.forEach(function (dataItem) { var columnDef = {}; columnDef.cellTemplate = '<div ng-if="row.entity.IsEnum" style="padding: 2px 5px;text-align:center;"><select style="width:100%;height:28px;border-radius:3px;" ng-model="selectedEnumItem" ng-options="item.Name for item in dicEnumItems"></select></div>'; columnDef.field = 'Value'; columnDef.displayName = 'Значение'; ... if(dataItem.IsEnum){ referenceService.getDicEnum($scope.userId, dataItem.TypeName).then(function (dicEnums) { $scope.dicEnumItems = dicEnums.data; }); } $scope.gridOptions.columnDefs.push(columnDef); } 

As a result, an array is written to dicEnumItems. But for some reason, the dropdown is empty.

Plunker Link: https://plnkr.co/edit/EDE7UBb07upwIQFzj5WG?p=preview

  • can you make an example on plunkr ? I'm pretty sure that the problem is with the isolate scope and most likely will help some in $parent.dicEnumItems But nowhere to check :-) - Grundy
  • I can not create yet. In the console, a bunch of errors fall. I wrote the main thing. Maybe because getDicEnum is asynchronous, and at the time of adding columnDef $scope.dicEnumItems still empty? But then it is not clear how to solve this problem. - endovitskiiy
  • The example should be minimal , it is not necessary to transfer the entire project. - Grundy
  • in the console it writes Failed to instantiate module ui.grid. Elementary can not connect the module ui.grid. Here is the link, if you are interested: plnkr.co/edit/EDE7UBb07upwIQFzj5WG?p=preview - endovitskiiy
  • Where is the link? You can add it to the question too - Grundy

1 answer 1

Here's a solution if someone needs it: https://plnkr.co/edit/U81BqnUPKzr3q7ngqszv?p=preview

This is important:

 ng-options="item.Name for item in row.entity.dicEnumItems" 

Adding dicEnumItems to row.entity :

 if (dataItem.IsEnum) { dataItem.dicEnumItems = $scope.getDicEnum(); } 

dataItem is row.entity.

  • one
    add how you added dicEnumItems to an entity , at least with the words - Grundy