thalla thalla - 19 days ago 8
jQuery Question

JQgrid : disable table header mouse hover style

How to disable jqgrid table header hover style.
I tried answer from this solution from another stackover flow question,

$($("#gridId")[0].grid.hDiv).find(".ui-jqgrid-labels th.ui-th-column")
.unbind("mouseenter")
.unbind("mouseleave");


it disable the header hover style but shows some error in console


Uncaught TypeError: Cannot read property 'grid' of undefined(…)

Answer

I suppose that you executed the code before the grid is created. You should just move the code to the correct place. See https://jsfiddle.net/3304edu4/, which uses

$($("#grid")[0].grid.hDiv)
    .find("th.ui-th-column")
    .off("mouseenter mouseleave");

By the way you can move the code inside of onInitGrid callback, which will be called after the outer part of the grid (for example column headers) are created:

onInitGrid: function () {
    $(this.grid.hDiv)
        .find(".ui-jqgrid-labels th.ui-th-column")
        .off("mouseenter mouseleave");
}

See https://jsfiddle.net/3304edu4/1/