How to highlight current row when clicking cell template button in angular ui interface

I included ui-grid-selection

in the grid. As a result, when a row is selected it will be highlighted, but my requirement is that I only want to highlight the row when the cell template button is clicked. Please let me know how to do this.

Sample code

0


source to share


1 answer


Finally was able to find a way to do it. Here's the answer .

What I've done,

  • The mesh option is changed enableRowSelection: false

    .
  • Add function to cell template button.

Button cell template



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

      

  1. Implement a function to select the given string obj.

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

if you want to deselect the selected row when the template button is pressed again, you can use row.isSelected

this will return a boolean. Here is an updated snippet of the function code.

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

      

+1


source







All Articles