您需要在ui-grid的3.x版本中使用 external-scopes 功能。之所以无法在选择下拉列表中获得任何选项,是因为ui-
grid现在使用隔离的作用域,这将不允许您在单元格中直接访问应用程序作用域变量。
我能够按照以下步骤操作您的plunkr-
查看最新的plunkr
脚步:
1) 在index.html中,在grid div中指定 external-scopes 属性,即修改
<div ui-grid="gridOptions" ui-grid-edit ></div>
至
<div ui-grid="gridOptions" ui-grid-edit external-scopes="myExternalScope"></div>
2) 在app.js中,将范围分配给我们的external-scope属性,即添加以下行:
$scope.myExternalScope = $scope;
3) 在temp.html中,使用 getExternalScopes() 访问sexTypes数组,即从以下位置修改
editableCellTemplate 值
<select ng-model="row.entity.Gender" data-ng-options="d as d.type for d in genderType">
至
<select ng-model="row.entity.Gender" data-ng-options="d as d.type for d in getExternalScopes().genderTypes">
额外的想法:
1)我没有找到适合我需要的 ui-grid / dropdownEditor- 因此,还没有尝试过。
2)您还可以将 cellTemplate 与 editableCellTemplate 一起添加。您可以分配两个相同的值。
参考文献:
- http://ui-grid.info/docs/#/tutorial/305_externalScopes



