2

I am trying to implement a hover effect on the rows of an Angular ui grid. 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.

This is the hover effect on the row header:

enter image description here

This is the hover effect on any other column:

enter image description here

Did anyone find a solution for this?

4
  • I didn't get your problem completely. Can you please rephrase the last line? Basically, I am not getting the desired behavior that you expect for the expanded grid. Commented Apr 5, 2016 at 6:39
  • I have tried to rephrase and added screen shots. Please have another look! Commented Apr 5, 2016 at 11:49
  • Did you tried to add <... ng-mouseover="rowStyle={\'background-color\': \'red\'};" ng-mouseleave="rowStyle={}" ...> to your row and expanded row template? Commented Apr 5, 2016 at 12:03
  • How can I add this to the row header? I think I cannot change the HTML, unfortunately. Commented Apr 5, 2016 at 12:10

1 Answer 1

0

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):

<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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.