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

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

问题描述

我已经启用上grid.As结果,当被选择的行它会彰显您的身份,但我的要求是,我想强调该行只有当细胞模板按钮clicked.Please让我知道如何为此.

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.

代码示例

推荐答案

最后找到了解决方法.这是 answer .

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); };

$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)
       }
  }; 

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

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