如何在角度 UI 网格中单击单元格模板按钮时突出显示当前行

How to highlight the current row when cell template button is clicked in angualar UI Grid

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 让我知道怎么做。

Code Sample

终于找到办法了that.Here就是answer.

我所做的是,

  1. 网格选项已更改 enableRowSelection: false
  2. 向单元格模板按钮添加功能。

按钮单元格模板

<div><button class="btn btn-default" ng-click="grid.appScope.selectRow(row)">O</button></div>
  1. 对给定行对象 select 执行一个函数。

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

如果您想在再次单击模板按钮时取消select编辑的行,您可以使用row.isSelected这将return布尔值value.Here 是更新后的函数代码片段。

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