"Troubleshooting: Difficulty with hover function in jqgrid not functioning on colored rows

My JQGrid setup includes the following:

<table id="grid"></table>

var data = [[48803, "DSK1", "", "02200220", "OPEN"], [48769, "APPR", "", "77733337", "ENTERED"]];

$("#grid").jqGrid({
    datatype: "local",
    height: 250,
    colNames: ['Inv No', 'Thingy', 'Blank', 'Number', 'Status'],
    colModel: [{
        name: 'id',
        index: 'id',
        width: 60,
        sorttype: "int"
    }, {
        name: 'thingy',
        index: 'thingy',
        width: 90,
        sorttype: "date"
    }, {
        name: 'blank',
        index: 'blank',
        width: 30
    }, {
        name: 'number',
        index: 'number',
        width: 80,
        sorttype: "float"
    }, {
        name: 'status',
        index: 'status',
        width: 80,
        sorttype: "float"
    }],
    caption: "Stack Overflow Example",
    gridComplete: function () {
        var rowIDs = $("#grid").getDataIDs();
        for (var i = 0; i < rowIDs.length; i++) {
            $("#grid").jqGrid('setRowData', rowIDs[i], false, {background : '#FF3300'});
            var trid = $("#grid tr#"+rowIDs[i]);
            if(trid.length > 0) 
                trid.addClass("manualreportgriderror");
        }
    }
});

var names = ["id", "thingy", "blank", "number", "status"];
var mydata = [];

for (var i = 0; i < data.length; i++) {
    mydata[i] = {};
    for (var j = 0; j < data[i].length; j++) {
        mydata[i][names[j]] = data[i][j];
    }
}

for (var i = 0; i <= mydata.length; i++) {
    $("#grid").jqGrid('addRowData', i + 1, mydata[i]);
}
$("#grid").jqGrid('setGridParam', {ondblClickRow: function(rowid,iRow,iCol,e){alert('double clicked');}});

I have color-coded rows in the grid as red after the grid's complete event.

If I remove the color on the rows, hover functionality works on the grid.

I attempted to add the following CSS:

.ui-state-hover-grid {
    background-color: yellow !important;
} 

But this applies yellow color throughout the application and not just on the grid.

How can I enable hover on colored rows? And apply a yellow background color only for grid rows when hovered over?

HTML Code:

<div class="ui-jqgrid ui-widget ui-widget-content ui-corner-all" id="gbox_grid" dir="ltr"... 

Thank you in advance.

Answer №1

Give this a shot

 <style>
 .ui-jqgrid .ui-state-hover {
   background: yellow !important;
}

This CSS code will apply to all elements in jqgrid. To prevent the headers from hovering, use the following script:

  var $grid = $('#list'), // select the grid
        hdiv = $grid[0].grid.hDiv, // get the DOM of the header div
        $columnHeaders = $("thead tr.ui-jqgrid-labels th", hdiv); // select the header elements
        $columnHeaders.unbind('mouseenter');
        $columnHeaders.unbind('mouseleave');

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I'm encountering difficulty accessing the Index value within the template's Ref

I'm having trouble accessing the index value inside the templateRef. It shows as undefined in the console. <ng-container *ngFor="let notification of notifications; let i = index"> <ng-template *ngTemplateOutlet="notificationPage ...

What is the best way to ensure a stable background image using CSS?

I have successfully created my navigation section and now I am working on the main body of the website. However, when I try to add a background image, it ends up appearing on the navbar as well. Can someone please assist me with this issue? Below is the HT ...

What is the best way to align three tables columns in a single row?

I am facing an issue with aligning the columns of three different tables in one line. I have tried applying CSS styling, but the columns still appear misaligned. How can I ensure that the columns are properly arranged in a single line? Below are my HTML/C ...

What is the best way to send props to a styled component without needing to convert them to transient props beforehand

Recently, I designed a custom Text component that accepts several props. These props are then forwarded to the styled component where specific styles are applied. However, I am facing an issue where I do not want these props to be passed down to the DOM, b ...

What is the best way to animate my logo using JavaScript so that it scales smoothly just like an image logo

I dedicated a significant amount of time to create a unique and eye-catching logo animation for my website! The logo animation I designed perfectly matches the size of the logo image and can be seamlessly integrated into the site. The issue arises when th ...

Issues with centering background-position while using clip-path functionality

Struggling to center a background image? I initially suspected conflicting CSS rules, so I created a simplified demo to troubleshoot. After reviewing examples on SO and beyond, it seems like my approach is correct. Can anyone help identify what I might be ...

Error arises on Github when submitting a pull request due to a conflicted package

When facing conflicts in the package.json file while submitting a pull request, what is the best approach to resolve them? I usually attempt using git pull origin, but it tends to generate numerous merge commits. ...

What causes the AngularJS variable to receive a null value following an HTTP request?

Using AngularJS on the frontend, I have a variable named ttest defined before making an $http call. Subsequently, data is assigned to this variable. The value of ttest[0] is available within the $http function but not outside of it. angular.module(&apos ...

Encountered an issue while trying to establish a connection between node.js and MongoDB

db connection error querySrv ENOTFOUND _mongodb._tcp.nodeapi.vlvom.mongodb.net (node:7720) UnhandledPromiseRejectionWarning: Error: querySrv ENOTFOUND _mongodb._tcp.nodeapi.vlvom.mongodb.net at QueryReqWrap.onresolve [as oncomplete] (dns.js:203:19) (Us ...

Keep track of the toggled state and prevent any flickering when the page is reloaded, all without the

After extensive searching, I couldn't find exactly what I needed. Therefore, I decided to utilize cookies to remember the toggled state of a div whether it's hidden or visible. However, I encountered an issue where there is flicker happening as t ...

Execute function prior to redirection of iframe

I have a specific challenge with an iframe on my webpage. I am looking to trigger a function right before the iframe reloads a new page, rather than after it has finished loading. I need this function to be triggered before the iframe redirects to the new ...

Personalized Horizontal Radio Button Design

I have been struggling to achieve the desired design for radio buttons but without success. https://i.sstatic.net/TU7Ks.png Despite using bootstrap for my website, I am only able to achieve this: https://i.sstatic.net/WbzqS.png This is the code I am cu ...

Incorporate time zone awareness to JavaScript date objects

Whenever I create objects in my MongoDB using Mongoose, the dates are displayed in the format of, for example, 2016-10-10T15:35:52.764Z (alternatively, it could be yyyy-MM-ddTHH:mm:ssZ). When I utilize Date.now() in JavaScript, I am given a timestamp. Is ...

Attempting to transmit unique symbols using JQuery Ajax to a PHP script

I am using JQuery Ajax to send special characters to a PHP file. sending_special_characters.js var special_chars = '!@#$%^&*()_+-='; var dataToSend = 'data=' + special_chars; $.ajax({ type: "POST", ...

MUI React: The Smallest Date Possible

Is there a way to ensure that the user cannot select a To Date that is earlier than the From Date? Below are my Two Date Pickers, with date formatting done using moment. <DatePicker v ...

Parallaxing with Jquery: Elevating Your Website Design

After searching through countless parallax tutorials, I realized there's a lot of unnecessary complexity for what I'm trying to accomplish. I have a feeling there might be a simpler way to achieve my goal without using plugins. All I want is to ...

Ruby on Rails slider bar functionality

Currently, I am developing a video-focused application using Ruby 1.9.2 and Rails 3.1. One of the key features I need to implement is a slider bar that allows users to adjust the total duration of a video in real-time. Despite my attempts to use HTML5 fo ...

Assist with JavaScript Programming

Can someone assist me in creating functionality for the "Show Picture" button to toggle the visibility of the picture when clicked? I've been trying to achieve this using an If/Else statement for a school project but have been struggling with it. Any ...

Explore the diverse webpages on my website

My website is built in html+css and the main content is contained within a div with the id "content" on index.html. There's a link on the menubar that leads to page2.php, but I want the content of page2.php to be displayed inside the <div "content" ...

Achieving perfect alignment of two elements using flexbox: centering one and aligning the other to the right

Can you help me with aligning two elements to the center and right edge using flex? I am trying to achieve a layout similar to the image. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX https://i.sstatic.net/cvmHX.png CSS Styles .flex{ display: flex; justify- ...