【问题标题】:Replace angular UI-GRID selection RowButton with checkbox用复选框替换角度 UI-GRID 选择 RowButton
【发布时间】:2023-03-24 15:40:02
【问题描述】:

我需要将 UI 网格选择标题内容替换为常规复选框而不是默认的确定按钮。 我能够插入复选框,但我无法根据列标题选中复选框来控制行复选框值。 要求:选中列标题复选框时,应选中所有行复选框。 当取消选中行复选框时,应取消选中列标题复选框。

选择/取消选择复选框有效,但我应该能够根据列标题复选框控制行复选框。

我在这里与范围作斗争。任何帮助/建议表示赞赏。

Plunker 链接:http://plnkr.co/edit/Ji7gLbfQTohnEj04mYFM?p=preview

 $templateCache.put('ui-grid/selectionRowHeaderButtons',
    "<div class=\"ui-grid-selection-row-header-buttons \" ng-class=\"{'ui-grid-row-selected': row.isSelected}\"><input style=\"margin: 0; vertical-align: middle\" type=\"checkbox\" ng-model=\"rowSelected\" ng-click=\"grid.appScope.clickConditionRow(rowSelected) && selectButtonClick(row, $event)\">&nbsp;</div>"
  );

【问题讨论】:

  • 你能给我们一些代码吗?
  • 请提供复制问题的 plunkr 链接。
  • 您好@Druid 感谢您的关注。我添加了指向 plunkr 的链接,其中包含代码和显示正在运行的 plnkr 的链接。我无法在 plunker 中预览,因此提供了一个单独的链接。
  • 你好@SaiGiridhar,我已经添加了 plunkr 链接。感谢您的观看。

标签: angularjs checkbox angular-ui-grid


【解决方案1】:

这里是修复http://plnkr.co/edit/aBmgnNXQ4fL0npJHzsfG?p=preview

标题复选框模板:

<div class="ui-grid-selection-row-header-buttons" ng-class="{'ui-grid-all-selected': grid.selection.selectAll}" ng-if="grid.options.enableSelectAll"><input style="margin: 0; vertical-align: middle" type="checkbox" ng-model="grid.selection.selectAll" ng-click="grid.selection.selectAll=!grid.selection.selectAll;headerButtonClick($event)"></div>

行复选框模板:

<div class="ui-grid-selection-row-header-buttons" ng-class="{'ui-grid-row-selected': row.isSelected}" ><input style="margin: 0; vertical-align: middle" type="checkbox" ng-model="row.isSelected" ng-click="row.isSelected=!row.isSelected;selectButtonClick(row, $event)">&nbsp;</div>

【讨论】:

  • 非常感谢@SaiGiridhar。这正是我想要的。
  • 行复选框模板对我有用,但不适用于标题复选框模板
猜你喜欢
  • 1970-01-01
  • 2015-05-28
  • 1970-01-01
  • 2013-06-29
  • 1970-01-01
  • 2017-11-08
  • 2023-03-15
  • 1970-01-01
  • 2022-10-13
相关资源
最近更新 更多