Need to change grid row border color when hover/focus

1 Answer 2122 Views
Grid Styling
lahiru
Top achievements
Rank 1
lahiru asked on 09 Aug 2022, 06:08 PM
Im using kendo grid angular and want to change every row of grid border when hover/focus to it

1 Answer, 1 is accepted

Sort by
0
Accepted
Kaloyan
Telerik team
answered on 10 Aug 2022, 11:53 AM

Hello lahiru,

To change the border of a grid row on hover you will need to apply some custom CSS that will select the first cell, the last cell and all cells in between of the targeted row. Here is the CSS I used for this:

    .k-grid tbody > tr:hover td:first-child{
        border-left: solid red;
    }     
    .k-grid tbody > tr:hover td:last-child{
        border-right: solid red;
    }    
    .k-grid tbody > tr:hover td{
        border-top: solid red;
        border-bottom: solid red;
    }

The idea is to apply top and bottom border to all cells and left and right border to the first and last cells.

Additionally, I am not entirely sure how this should behave on focus instead of hover. This is mainly because the grid component doesn't have row focus out of the box and achieving such functionality might prove cumbersome. If by focus you mean on select, then the logic is similar as above, with the only difference that you use the k-selected class:

    .k-grid tbody > tr.k-selected td:first-child{
        border-left: solid red;
    }     
    .k-grid tbody > tr.k-selected td:last-child{
        border-right: solid red;
    }    
    .k-grid tbody > tr.k-selected td{
        border-top: solid red;
        border-bottom: solid red;
    }
The working sample can be found in this stackblitz.

Please, let us know if you will require further assistance.

Regards,
Kaloyan
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


lahiru
Top achievements
Rank 1
commented on 13 Aug 2022, 03:17 PM

It works.. thanks
Tags
Grid Styling
Asked by
lahiru
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Share this question
or