[英]angularjs ng-grid dropdown not working with order by
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. 我有一个角度网格(ng-grid),其中一列以上都有一个下拉菜单,该下拉菜单绑定到行中显示的对象的属性。
<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: 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?
我将如何解决这个问题?
Ok, found the issue. 好的,找到了问题。 To reference the original object you need to change
要引用原始对象,您需要更改
AnimalData[ row.rowIndex ].type
to row.entity.myEditableProperty.type
AnimalData[ row.rowIndex ].type
到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 概念证明Plunkr: http ://plnkr.co/edit/i7vXng?p = preview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.