问题
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.
Code Sample
回答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)
}
};
来源:https://stackoverflow.com/questions/39244455/how-to-highlight-the-current-row-when-cell-template-button-is-clicked-in-anguala