在Angular Bootstrap中的某些行上禁用表悬停

问题描述:

我有一个显示可选信息的表.有时有些子行是可选的.

I have a table that displays selectable information. Sometimes there are child rows that are selectable.

如果父行没有子行,我希望它们是可选的,否则,只有子行应该是可选的.这是仅选择一种类型的表.

I want the parent rows to be selectable if they have no children, otherwise only the child rows should be selectable. This is a select-only-one type of table.

此表按预期工作.但是,我想在不可选择的父行上禁用悬停.

This table works as expected. However, I want to disable the hover on the non-selectable parent row.

这是一个工作正常的人: http://plnkr.co/edit/Z0cgHKx2qxpekEE36O1K?p=预览

Here is a working plunker: http://plnkr.co/edit/Z0cgHKx2qxpekEE36O1K?p=preview

这是控制器中一些代码的示例:

Here is an example of some of the code in the controller:

    scope.parentSelected = [];
$scope.childSelected = [];

$scope.getParentDetails = function(parentObj) {
  if(!parentObj.jobs || parentObj.jobs.length === 0) {
    nonSelectOtherRows(); 
    var index = $scope.pro.indexOf(parentObj);
    $scope.parentSelected[index] = !$scope.parentSelected[index];

    // get details for parent row using parentObj
    console.log(parentObj);
  } 
};

$scope.getChildDetails = function(parentObj, childObj) {
  nonSelectOtherRows();
  var parentIndex = $scope.pro.indexOf(parentObj);
  var childIndex = parentObj.jobs.indexOf(childObj);
  $scope.childSelected[parentIndex] = [];
  $scope.childSelected[parentIndex][childIndex] = !$scope.childSelected[parentIndex][childIndex];

  // get details for parent and child rows using parentObj and childObj.
  // childObj is the childRow selected
  console.log(parentObj);
  console.log(childObj);
}

删除 table-hover 属性.

实现您的 ng-mouseover ng-mouseleave 函数.

$scope.hoverIn = function(row){
   row.hoverEdit = true;//check selectable or not
};
$scope.hoverOut = function(row){
   row.hoverEdit = false;
};

为悬停定义css类.

.custom-hover {
  background-color: red;
}

最后将类添加到您的 tr

`'custom-hover': x.hoverEdit`

此处是: http://plnkr.co/edit/CJxi86GyM8jMbtehPQgU?p=preview一个>将您的可选控件添加到hoverIn内,它将起作用.

here is: http://plnkr.co/edit/CJxi86GyM8jMbtehPQgU?p=preview Add your selectable control inside hoverIn and it will be work.