0

I have an angular grid (ng-grid) where one ove the columns has a dropdown which is bound to a property of the objects displayed in the rows.

<div class="gridStyle span9" ng-grid="gridOptions"></div> 

$scope.types = ['cat', 'dog' 'rat'];

    $scope.gridOptions = {
    data : 'AnimalData',
    columnDefs : [{
        field : 'name',
        displayName : 'Name'
    }, {
        field : 'birthday',
        displayName : 'Birthday'
    },{
        field : 'type',
        displayName : 'type'
        cellTemplate : 'cellTemplate.html'
    }]
};

cellTemplate.html:

<div>
  <select ng-model="AnimalData[ row.rowIndex ].type">
    <option ng-repeat="item in types">{{item}}</option>
  </select>
</div>

This binds to my objects perfectly well but when I order my grid the dropdowns do not order they just stay in the same place with the values not changing. How would i go about fixing this?

1 Answer 1

1

Ok, found the issue. To reference the original object you need to change

AnimalData[ row.rowIndex ].type to row.entity.myEditableProperty.type

eg:

<div><select ng-model="row.entity.myEditableProperty.type" ng-options="item for item in types"></select></div>

Proof of concept Plunkr: http://plnkr.co/edit/i7vXng?p=preview

Sign up to request clarification or add additional context in comments.

1 Comment

Unfortunately get the same result if I do it this way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.