问题
- I’m trying to add a dropdown to my “Type” column where I can select either x, y, or z.
- When I select x, y, or z in the dropdown, the checkboxes for the x, y, z columns don’t change.
However, when I check the either x,y or z checkboxes, the downdrop value in the “Type” column changes
{ name: 'Type', displayName: 'Type', width: '7%',field:'getType()', editableCellTemplate: 'ui-grid/dropdownEditor', editDropdownValueLabel: 'Type', enableCellEdit: true },
Here's my plunker: https://plnkr.co/edit/mzSaxh3PVvqvfJtAYKkU?p=preview
回答1:
This should do it...
$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>'
Your Plunker updated, https://plnkr.co/edit/SbZkKubGtrzWYJhc8Qv9?p=preview.
来源:https://stackoverflow.com/questions/43452977/how-to-handle-dynamic-dropdowns-for-ui-grid