在角度 UI 网格中单击单元格模板按钮时如何突出显示当前行 [英] How to highlight the current row when cell template button is clicked in angualar UI Grid

查看:17
本文介绍了在角度 UI 网格中单击单元格模板按钮时如何突出显示当前行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have enabled ui-grid-selection on grid.As a result that when row is selected it will be get highlighted but my requirement is that i want to highlight the row only when the cell template单击按钮.请告诉我如何执行此操作.

I have enabled ui-grid-selection on grid.As a result that when row is selected it will be get highlighted but my requirement is that i want to highlight the row only when the cell template button is clicked.Please let me know how to do this.

代码示例

推荐答案

终于能够找到一种方法来做到这一点.这里是 答案.

Finally was able to find a way to do that.Here is the answer.

我所做的是,

  1. 在网格选项中更改了 enableRowSelection: false.
  2. 向单元格模板按钮添加函数.

按钮单元格模板

<div><button class="btn btn-default" ng-click="grid.appScope.selectRow(row)">O</button></div>

  1. 实现一个函数来选择给定的行 obj.

  1. Implement a function to select given row obj.

$scope.selectRow = function(row) {row.setSelected(true);};

如果您想在再次单击模板按钮时取消选择所选行,您可以使用 row.isSelected 这将返回布尔值.这是更新的函数代码片段.

if you want to unselect the selected row when the template button is clicked again you can use row.isSelectedthis will return boolean value.Here is the updated function code snippet.

$scope.selectRow = function(row) {
       if(row.isSelected!=true){
         //Select the row
         row.setSelected(true)
       }else{
          row.setSelected(false)
       }
  }; 

这篇关于在角度 UI 网格中单击单元格模板按钮时如何突出显示当前行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆