This is a migrated thread and some comments may be shown as answers.

Grid row hover effect?

15 Answers 3430 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
T
Top achievements
Rank 1
T asked on 02 Apr 2012, 04:03 PM
How can I turn on (or create) a subtle hover highlight for rows when my grid is row-selectable?  

This should be a built-in feature since such an effect should look good within the chosen theme.  

If it's not, can you suggest some CSS and what class to apply it to that would use theme-friendly hover highlighting?

15 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 02 Apr 2012, 04:48 PM
Hi,

You can use:

.k-grid > table > tbody > tr:hover,
.k-grid-content > table > tbody > tr:hover
{
        background: ........ ;
}

The two selectors are for Grids without scrolling and with scrolling, respectively.

For a theme-friendly look, you can use Javascript and apply the k-state-hover CSS class to the currently hovered row.

Kind regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Vince
Top achievements
Rank 1
answered on 03 Apr 2012, 01:02 AM
It's more complicated then this.  It needs to be able to update/render each cell, since the hover style could conflict with the font, etc.
What is needed is to have another row.state for "hover", along with css etc to go with it.
Thanks
0
T
Top achievements
Rank 1
answered on 03 Apr 2012, 02:59 AM
I implemented this with javascript but it fails after the grid is sorted.  What's the best way to handle that?

    addExtraStylingToGrid = function() {
        // add row hilighting on hover and make sure to remove it on click
        $(rowQueryString).hover(
            function () {
                $(this).addClass('k-state-hover');
            },
            function () {
                $(this).removeClass('k-state-hover');
            }
        );
        $(rowQueryString).click(
            function () {
                $(this).removeClass('k-state-hover');
            }
        );
    }

0
Dimo
Telerik team
answered on 03 Apr 2012, 07:11 AM
Hello,

You need to execute the script in the dataBound event handler, i.e. after sorting, paging, etc. This is because the row DOM elements are replaced in these cases.

Kind regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
T
Top achievements
Rank 1
answered on 03 Apr 2012, 12:34 PM
So far dataBound works great, thanks!
0
Vince
Top achievements
Rank 1
answered on 03 Apr 2012, 02:20 PM
Can you post your code.  Thanks
0
T
Top achievements
Rank 1
answered on 03 Apr 2012, 03:03 PM
It's the "addExtraStylingToGrid()" code I posted above.  The missing element is to add

   dataBound:addExtraStylingToGrid

in the grid configuration options.

0
whibs
Top achievements
Rank 1
answered on 08 Sep 2012, 04:54 PM
Here's a working demo if you'd like to check it out:
http://jsbin.com/ezovaw/2/edit 
0
Lee
Top achievements
Rank 1
answered on 20 Nov 2012, 05:00 PM
In this referenced JSBin example the row selection style and the row hover style are both showing up as gradients....I am only able to get the solid color to appear.....What am I missing?
0
Lee
Top achievements
Rank 1
answered on 20 Nov 2012, 05:04 PM
It is the public, static style sheets that are different than the ones I have from my purchase....
0
Andrew
Top achievements
Rank 1
answered on 21 Jun 2013, 04:31 AM
I think the problem here is the version of KendoUI
I tried the code with the latest kendoui release and jquery 1.9.1 and it does not work at all.

http://fiddle.jshell.net/zawisza/47J8M/
0
Dimo
Telerik team
answered on 21 Jun 2013, 09:00 AM
Hi Andrew,

The following expression

$("table.k-focusable tbody tr")

does not return anything, because the Grid table does not have a k-focusable class.

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Andrew
Top achievements
Rank 1
answered on 21 Jun 2013, 09:08 AM
Dimo,
Is there a replacement?
How would one do this with the current version?
0
Dimo
Telerik team
answered on 21 Jun 2013, 11:57 AM
Hello Andrew,


Inspecting the Grid HTML reveals that the widget wrapper (the table's parent <div>) always has a k-grid class applied, so you can use that element in the selector.

$(".k-grid > table > tbody > tr")


Note that <div class="k-widget k-grid"> is a direct parent of the Grid table only when scrolling is disabled. If scrolling is enabled, the table's parent is different.
 

$(".k-grid-content > table > tbody > tr")

 

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Andrew
Top achievements
Rank 1
answered on 22 Jun 2013, 04:13 AM
Thanks. That works perfectly. 
Tags
Grid
Asked by
T
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Vince
Top achievements
Rank 1
T
Top achievements
Rank 1
whibs
Top achievements
Rank 1
Lee
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Share this question
or