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.
Asked
Active
Viewed 546 times
0

gihan-maduranga
- 4,381
- 5
- 41
- 74
1 Answers
1
Finally was able to find a way to do that.Here is the answer.
What i did was,
- In grid option changed
enableRowSelection: false
. - Add a function to cell template button.
Button Cell Template
<div><button class="btn btn-default" ng-click="grid.appScope.selectRow(row)">O</button></div>
Implement a function to select given row obj.
$scope.selectRow = function(row) { row.setSelected(true); };
if you want to unselect the selected row when the template button is clicked again you can use row.isSelected
this 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)
}
};

gihan-maduranga
- 4,381
- 5
- 41
- 74
-
ok..but one issue I found..(i don't know if that is a issue or your requirement) once a row is selected it is not deselecting even though you select some other row. – Sarun UK Aug 31 '16 at 12:59