Is it feasible to customize the icon for the expand/collapse button in the header of jqGrid?

To begin, let me provide some context.

In my view, I have 2 or more grids (jqgrid) and I aim to insert an "X" into the expand/collapse button.

After several attempts, I successfully added the "X" icon to all grids using this code:

 .ui-icon-circle-triangle-n
    {
        background-position: -31px -192px !important;
    }

1 - How can I change only the icon of the expand/collapse button in a specific grid?

Answer №1

When using jqGrid, the "Close" button in the caption layer utilizes icons like "ui-icon-circle-triangle-n" and "ui-icon-circle-triangle-s". If you'd like to change the "ui-icon-circle-triangle-n" icon to something else, such as "ui-icon-closethick" (refer to jQuery UI CSS Framework), follow these steps:

  1. To change the default icon when creating the grid:
$(".ui-jqgrid-titlebar>.ui-jqgrid-titlebar-close>span")
    .removeClass("ui-icon-circle-triangle-n")
    .addClass("ui-icon-closethick");
  1. Change the icon within the onHeaderClick callback after opening the grid:
onHeaderClick: function (gridstate) {
    if (gridstate === "visible") {
      $(this).closest(".ui-jqgrid-view")
          .find(".ui-jqgrid-titlebar>.ui-jqgrid-titlebar-close>span")
          .removeClass("ui-icon-circle-triangle-n")
          .addClass("ui-icon-closethick");
    }
}

For a demo showcasing the results, visit here:

Answer №2

Assuming that the ID of the first grid container is grd_asset_container, simply target this grid using the following:

#grd_asset_container div.ui-jqgrid-titlebar .ui-icon-circle-triangle-n, #grd_asset_container div.ui-jqgrid-titlebar .ui-icon-circle-triangle-s { background-position: -32px -192px !important; }

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

Using Google Maps to Cluster Markers on Your Website

I need to display numerous markers on a map for my website. My inquiry is whether the google maps api for javascript still supports clustering for websites? I attempted using marker cluster and it seems like it's not functioning properly. If so, can ...

Sticky Sidebar Attached to Parent Container with Smooth Sliding Effect

Is it possible to have my sidebar push the content across when opened, while keeping the fixed navigation relative to its parent element instead of the viewport? The sidebar works fine in Firefox but breaks out of the parent in Chrome. Link to JSFiddle & ...

Encountering a 500 error while using AJAX in an MVC POST request, although it is functioning

I've been working on saving booking information using ajax. https://i.sstatic.net/9VrFO.png https://i.sstatic.net/TNdyD.png https://i.sstatic.net/71zE5.png https://i.sstatic.net/HVW16.png https://i.sstatic.net/B2E03.png https://i.sstatic.net/9GPT ...

Updating radio button color upon selection in Boostrap

Looking to customize the colors of radio buttons found on this Bootstrap page By default, the background color is white and changes to blue when clicked. <div class="btn-group" role="group" aria-label="Basic radio toggle button ...

Struggling with getting Bootstrap Affix-bottom to scroll back up?

Despite reading various answers, I am still struggling to configure the settings correctly. The columns header is not resuming scrolling upwards as expected. Below is my PHP code snippet: <div id="columnsHeader" class="affix" data-offset-top="800" da ...

Place elements in a grid layout using CSS (and also ensure they are centered)

My goal is to create a data-grid (table layout) where the elements have fixed sizes. These elements should be placed in the same line until they can't fit anymore, then move to the next line. I have tried using inline-blocks for this, but I'm st ...

Tips for Enhancing the Appearance of a List Input Box

While on my hunt for an auto-completing text field, I stumbled across lists. <label>Bad Habit <input list="badhabits" id="habits" name="habit"/> </label> <datalist id="badhabits"> <option value="alcoholics"> <option ...

What is the best way to show a table with 100% width in the Chrome browser?

I am currently working on debugging and expanding an express application that showcases a dataset through a series of nested tables on a webpage. Initially, all the CSS resided within style tags in the head section of the HTML file, and the tables were dis ...

When using Javascript's querySelector, often times it returns null

Here is the HTML code I am working with: <button class="pop-btn"> Pop </button> While I was able to style this button using CSS, I encountered a problem when trying to select it in Javascript: const Population_div_Button=document. ...

"Storing" the chosen option from a dropdown list into a specific property

I'm currently working on a small "Rent a car" application using ASP.NET MVC. My goal is to create a page for administrators where they can add cars to be offered to customers. On this page, they should be able to input details such as the picture of ...

CSS Animation glitch with images

I am currently facing an issue with a slide that transitions between four pictures. The slide is set at a specific pace, but I am encountering a problem with the transition from the last slide back to the first one. I have attempted various solutions such ...

Content on iPad is not properly aligned with the gap below it

I have a webpage with links in the center and a div floated to the right, taking up about 25% of the screen. There is another div with position: fixed, left: 0, bottom: 0. On my desktop, using Firefox, the image inside the fixed position div appears in the ...

The second pop-up modal fails to appear

I have successfully implemented 2 modal windows with the help of bootstrap. The first modal is used for adding a user to the database, and the second one is meant for editing an existing user. While the first modal works perfectly fine, the editing modal d ...

Understanding Foreign Keys and Seeds in Entity Framework

Currently, I have 3 tables that are structured as follows: public class Parkings { [Key] public int ParkId { get; set; } [Required] public string StartDate { get; set; } [Required] public string EndDate ...

Issue with Modal Box: Datepicker not Displaying Correctly

I have implemented a modal box in my webpage. When I click on a text field where a datepicker is added, it does not display anything. However, when inspecting the element using Chrome's developer tools, I can see that the 'hasDatepicker' cla ...

How to position one div next to another using CSS and HTML

Hey there, I'm facing an issue with creating a sidenav next to a div containing paragraphs and images. I can't seem to make both the sidenav and the other div appear inline. If anyone has any insights on how to solve this problem or spot what I&a ...

Display the background-image of the <body> element only when the image has finished loading

I have a webpage where I want to delay showing a large image until it has finished downloading. Instead, I would like to display a background with a fading effect while the image loads. The challenge is that the background image must be set within the bod ...

The anchor tag <a> is configured for inline display but is unexpectedly occupying the entire space

I am currently incorporating Bootstrap into my HTML, however, the <a> tag is behaving like a block display despite the fact that I have specified the CSS to be display:inline; <!doctype html> <html> <head> <link rel="styleshee ...

Is it possible to develop Hybrid Apps specifically for Windows Tablets/Surface devices?

We have created a Hybrid App for Android devices and made it compatible with Windows by using Adobe PhoneGap Build to generate a .XAP package from the existing Source Code. We believe that this .XAP package can easily be deployed on a Windows Mobile devic ...

The JSON outcome lacks a constructor that supports 0 arguments

While trying to create my JSON action, I ran into an issue. The problem lies in the fact that when I try to return a JsonResult, it is being flagged with an error message stating 'JSON result does not contain a constructor that takes 0 arguments&apos ...