Marcus Leon
Marcus Leon

Reputation: 56669

jqGrid disable row highlighting

How can you programatically disable the grid from highlighting a row when you hover over it with your mouse? Looking to do disable this only at certain times.


This is the code from Oleg which worked:

  $('#result-close').click(function() {  
      //Turn off hover highlighting
      $("#list").unbind('mouseover');
      $("#list").unbind('mouseout');

      //Highlight row                    
      $("#" + selid).effect("highlight", {}, 5000);  

      //Turn on hover highlighting 
      setTimeout(function(){ 
                    $("#list").bind('mouseover',function(e) {
                        ptr = $(e.target).closest("tr.jqgrow");
                        if($(ptr).attr("class") !== "subgrid") {
                            $(ptr).addClass("ui-state-hover");
                        }
                        return false;
                    }).bind('mouseout',function(e) {
                        ptr = $(e.target).closest("tr.jqgrow");
                        $(ptr).removeClass("ui-state-hover");
                        return false;
                    });
      }, 2000);         

      $('#dialog').dialog( "close" );
  });

Upvotes: 7

Views: 19789

Answers (3)

SystemParadox
SystemParadox

Reputation: 8647

I'm currently replacing the existing mouseover handler with an intermediate function that just calls the existing handler if the grid is enabled, like this:

var enabled = true;
var jqe = jQuery("#grid");
var mouseover = jqe.data('events').mouseover[0].handler;
jqe.unbind('mouseover');
jqe.bind('mouseover', function() {
    if (enabled) {
        mouseover.apply(this, arguments);
    }
});

This way I don't have to copy the jqgrid event code.

I don't like the use of mouseover[0].handler, but it works for the moment.

Upvotes: 0

Oleg
Oleg

Reputation: 221997

Use hoverrows:false option.

Upvotes: 25

ChessWhiz
ChessWhiz

Reputation: 4702

A simple Google search revealed this source: http://www.trirand.net/examples/appearance/highlight_on_hover/default.aspx

"By default, jqGrid hightlight rows on hover. This is controlled by the AppearanceSettings.HighlightRowsOnHover property - setting it to false will disable that."

Upvotes: 0

Related Questions