简体   繁体   English

角度UI网格:将鼠标悬停在可扩展行上

[英]Angular UI-Grid: Hover on expandable row

I am trying to implement a hover effect on the rows of an Angular ui grid. 我正在尝试在Angular ui网格的行上实现悬停效果。 When the user hovers anywhere on the row, the complete row is supposed to change its background color. 当用户将鼠标悬停在该行的任何位置时,整个行应更改其背景颜色。 However, I am using the expandable grid, which automatically creates a row header with the expand icon. 但是,我使用的是可扩展网格,该网格会自动使用扩展图标创建行标题。 Now the CSS rules either color the row header area or the data area, but never the complete row. 现在,CSS规则为行标题区域或数据区域着色,但不会为整个行着色。

This is the hover effect on the row header: 这是对行标题的悬停效果:

在此处输入图片说明

This is the hover effect on any other column: 这是任何其他列上的悬停效果:

在此处输入图片说明

Did anyone find a solution for this? 有人找到解决方案了吗?

Here is what I did: 这是我所做的:

In the right part of the table, I added the following to the cell template: 在表格的右侧,我将以下内容添加到了单元格模板中:

<div class="ui-grid-cell-contents" 
     ng-class="{ 'ui-grid-cell-hover': (grid.appScope.hoverRow == row.uid) }"
     ng-mouseenter="grid.appScope.hoverRow = row.uid"
     ng-mouseleave="grid.appScope.hoverRow = undefined">

To cover the left part, I changed the expandableRowHeader template (in the template cache, since it is not exposed externally): 为了覆盖左侧部分,我更改了expandableRowHeader模板(在模板缓存中,因为它没有在外部公开):

<div class="ui-grid-row-header-cell ui-grid-expandable-buttons-cell">
    <div class="ui-grid-cell-contents"
         ng-class="{'ui-grid-cell-hover': (grid.appScope.hoverRow == row.uid)}"
         ng-mouseenter="grid.appScope.hoverRow = row.uid"
         ng-mouseleave="grid.appScope.hoverRow = undefined">
         ...
    </div>
</div>

I do not like this solution. 我不喜欢这种解决方案。 Firstly, I do not like patching a third party component. 首先,我不喜欢修补第三方组件。 Secondly, the hover reacts slow: it takes half a second until between hover and color change. 其次,悬停反应缓慢:在悬停和颜色更改之间需要半秒钟。

So in case someone has a better solution, please post it here. 因此,如果有人有更好的解决方案,请在此处发布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM