如何处理ui-grid的动态下拉列表?

时间:2017-04-17 14:00:26

标签: angularjs angular-ui-grid ui-grid

  • 我正在尝试在“Type”列中添加一个下拉列表,我可以在其中选择x,y或z。
  • 当我在下拉列表中选择x,y或z时,x,y,z列的复选框不会更改。
  • 但是,当我选中x,y或z复选框时,“Type”列中的downdrop值会发生变化

    { name: 'Type', displayName: 'Type', width: '7%',field:'getType()',  editableCellTemplate: 'ui-grid/dropdownEditor', 
             editDropdownValueLabel: 'Type', enableCellEdit: true },
    

这是我的傻瓜:https://plnkr.co/edit/mzSaxh3PVvqvfJtAYKkU?p=preview

1 个答案:

答案 0 :(得分:0)

应该这样做......

$scope.updateType = function (entity, type) {
  entity.xBox = type == 'x';
  entity.yBox = type == 'y';
  entity.zBox = type == 'z';
}

editableCellTemplate: '<select ui-grid-edit-dropdown ng-init="result=row.entity.getType()" ng-options="type for type in [\'x\',\'y\',\'z\']" ng-model="result" ng-change="grid.appScope.updateType(row.entity, result)"></select>'

您的Plunker已更新,https://plnkr.co/edit/SbZkKubGtrzWYJhc8Qv9?p=preview