在Angualar UI Grid中单击单元格模板按钮时如何突出显示当前行 [英] 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 let me know how to do this.
推荐答案
最后找到了解决方法.这是 answer .
Finally was able to find a way to do that.Here is the answer.
我所做的是
- 在网格中的选项已更改为
enableRowSelection: false
. - 向单元格模板按钮添加功能.
纽扣单元格模板
<div><button class="btn btn-default" ng-click="grid.appScope.selectRow(row)">O</button></div>
-
实现选择给定行obj的函数.
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.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)
}
};
这篇关于在Angualar UI Grid中单击单元格模板按钮时如何突出显示当前行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!