We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

When i change the cell background color the cell does not highlight when the mouse hovers over it

Thread ID:

Created:

Updated:

Platform:

Replies:

129324 Mar 13,2017 10:04 AM UTC Mar 14,2017 12:20 PM UTC ASP.NET MVC 1
loading
Tags: Grid
Andrew Simpson
Asked On March 13, 2017 10:04 AM UTC

i am using the querycellinfo clientsideevent to change the background color of a cell to red

ie
 function querycellinfo(args) {
args.cell.style.backgroundcolor = "red";
}

however when i do that the cell does not highlight when the mouse hovers over it.
how can i change the background color without losing the css for the mouse hover.
or change the css for the cell back to the default values for the mouse hover

thanks
andrew


Saravanan Arunachalam [Syncfusion]
Replied On March 14, 2017 12:20 PM UTC

Hi Andrew, 
Thanks for contacting Syncfusion’s support. 
We understood from your query, you need to toggle the hover style on the customized cell (by queryCellInfo event) when mouse hovering on the Grid’s rows and we have achieved it by using dataBound event of ejGrid control. In dataBound event, we have bound the jQuery’s mouseenter and mouseleave event to cell elements in the Grid for toggle the hover css on customized cell. Please refer to the below code example and jsplayground sample. 
[CSS]    
<style> 
        .red{ 
            background-color: red; 
        } 
    </style> 
     
[JS]         
            $("#Grid").ejGrid({ 
                dataSource: data, 
                allowPaging: true, 
                queryCellInfo: function(args){ 
                    var val = ej.getObject("Freight", args.data); 
                    if(args.column.field == "Freight" && val>50 && val<100) 
                       $(args.cell).addClass("red"); //Change the background color of cell 
                }, 
                dataBound: function(args){ 
                    var proxy = this; 
                    this.getContent().find("tr td").on("mouseenter mouseleave", function(e){ 
                        ele = $(e.target).closest("tr").find("td.red"); 
                        if(e.type == "mouseenter") 
                            ele.removeClass("red").addClass("normal"); //remove red and add normal class when hover mouse                      
                    })                 
                    this.getContent().find("tr td").on("mouseleave", function(e){  
                         ele = $(e.target).closest("tr").find("td.normal"); 
                         if(e.type == "mouseleave") 
                            ele.addClass("red").removeClass("normal"); //remove normal and add red class when leave mouse   
                    })                      
                }, 
                . . . 
        }) 
        
 
 
Regards, 
Saravanan A. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;