How to handle dynamic dropdowns for ui-grid?

别说谁变了你拦得住时间么 提交于 2019-12-12 22:21:49

问题


  • 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!