Reputation: 1101
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?
Upvotes: 0
Views: 1814
Reputation: 224
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
Upvotes: 1