Ways to create the initial row text in jqgrid treegrid appear bold

Trying to make the text in the first row of a jqgrid treegrid bold? Here's what I attempted:

#tree-grid .cell-wrapper {
    font-weight: bold;
}

However, this makes all nodes bold. How can I make only the first node (first row) bold?

The treegrid is defined as follows:

var treegrid = $("#tree-grid");
treegrid.jqGrid({
    loadComplete: function (data) {
        $('.tree-leaf', $(this)).css('width', '0px');
    },
    datatype: "json",
    mtype: "POST",
    height: "auto",
    loadui: "disable",
    treeGridModel: "adjacency",
    colModel: [
            { name: "id", width: 1, hidden: true, key: true },
            { name: "menu", classes: "treegrid-column" },
            { name: "url", width: 1, hidden: true }
        ],
    autowidth: true,
    treeGrid: true,
    ExpandColumn: "menu",
    rowNum: 2000,
    ExpandColClick: true,
});
treegrid.parents("div.ui-jqgrid-view").children("div.ui-jqgrid-hdiv").hide();

Update:

I also tried:

#tree-grid .cell-wrapper :first-child {
    font-weight: bold;
}

This didn't apply the bold font. The element shown in Firebug is a span with class "cell-wrapper" which contains the text that should be bold. It seems like :first-child doesn't work for this style.

Is it possible to use the second grid row element with

<tr id="1" class="ui-widget-content ..
to select and style the text within the corresponding cell?

Firebug displays the complete jqgrid layout as:

<div>
<div id="gbox_tree-grid" class="ui-jqgrid ui-widget ui-widget-content ui-corner-all" dir="ltr" style="width: 188px;">
...

Update 2:

Following Oleg's suggestion, I added the CSS rule:

.first-row {
    font-weight: bold;
}

And used:

rowattr: function (rd) {
    alert('rowattr');
    return {"class": "first-row"};
},

The alert box did not appear. Also, how do I apply this styling specifically to the first row in the treegrid?

Update 3:

After upgrading to version 4.4.1 per Oleg's advice, the text is still not bold. Firebug shows conflicting styles being applied after the "first-row" class. This is likely preventing the desired effect.

The code snippet used to open the tree on load is:

gridComplete: function () {
    setTimeout(function () {
          var rData2 = treegrid.getGridParam('data');
          treegrid.expandRow(rData2[0]);
          treegrid.expandNode(rData2[0]);
       },0);
},

In version 4.4.4, the tree does not expand correctly. In version 4.4.1, it works fine. What is the correct way to make the first node bold and expand it properly in the treegrid?

Answer №1

To tackle the issue, consider using the rowattr function to make an entire row bold. You can specify additional class or style attributes for the desired row. Another option is to utilize cellattr to apply styling only to a specific cell, such as those in the "menu" column. While the referenced examples use standard grids, the same approach can be applied to TreeGrids by leveraging rowattr and cellattr. Accessing columns like parent, level, and isLeaf in TreeGrid can aid in your implementation.

UPDATED: Check out this demo where all items without a parent are highlighted in bold.

Here is another demo with a more specific rule:

In both cases, a CSS rule was used:

.ui-jqgrid tr.myMarking td { font-weight: bold; }

The implementation of rowattr is straightforward, like the example below:

rowattr: function (rd) {
    if (rd.parent === "null" && rd.name === "Cash") {
        return {"class": "myMarking"};
    }
}

Answer №2

#tree-grid .cell-wrapper:first-child
{
    font-weight: bold;
}

To emphasize the first element in your CSS styling, simply target the 'first-child' using the appropriate selector.

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

Is it possible to change the background color of a Bootstrap button using CSS overrides?

Desired Outcome https://i.sstatic.net/EjEXG.gif Actual Result https://i.sstatic.net/BmXYG.gif The goal is to toggle the red-background class, so that when hovering over the button-bullet, its background-color changes to #FCC1C5. Avoiding the use of .b ...

Encountering an error message stating, "Unable to interpret property

I need to retrieve specific information import React,{Component} from 'react'; import axios from 'axios'; import CoinsConvert from '../data/data' import '../style/bootstrap.min.css'; class BoxInfo extends Component ...

Is there a way to use findByIdAndUpdate() without inadvertently removing any existing data?

Imagine a scenario where there is a mongoose Person model structured as below: const PersonSchema = new mongoose.Schema({ name: String, address: { street: String, number: number } }); Now, consider a method designed for updati ...

The signup process is experiencing the unusual occurrence of the Catch block being executed before the

I've encountered an issue where the catch block in my signup process is being triggered before the try block. Upon signing up, the error message from the catch block appears before the success message, which is not the expected behavior. Ideally, I wo ...

Encountering an issue with a <a> tag containing a <div> element with two columns

After coding this with a global tag <a>, I encountered an issue where the link ID was defined and appeared at the bottom wherever my mouse hovered. <a class="link" href="opencl/toto.htm"> <div class=&quo ...

ReactJS Error: The property 'hubConnection' is not defined on type 'JQueryStatic'

I am currently working with the Signalr library in React, but I keep encountering the following error: Property 'hubConnection' does not exist on type 'JQueryStatic'. Is there a solution to this issue? declare var window : any; import ...

Evaluating TypeError in CoffeeScript using Jasmine with Backbone.js

Currently, I am following the PeepCode video tutorial on Backbone.js, but I am rewriting all the code in CoffeeScript instead of plain JavaScript. Everything is going well so far, except when I attempt to run Jasmine tests on the code, I encounter some Ty ...

The phone number is not able to be clicked on

I have a phone number included in my markup that I would like to make clickable. Here is the code snippet: <h3 class="footer">Need assistance? Call <a href="tel:+180006XXXX">1800 06X XXX</a></h3> However, upon running this code, I ...

The challenge of synchronizing Javascript and PHP code

I am trying to trigger a JavaScript function with parameters retrieved from MySQL and have it execute on an onClick event. Below is the JavaScript code that I am using: function getFile() { if (window.XMLHttpRequest) { AJAX=new XM ...

Tips for refreshing a live ajax call to animate a circle

Currently, I am utilizing the gaugeMeter plugin to dynamically display the CPU usage of my elasticSearch Host. While the values are being displayed correctly, there seems to be an issue with the animation of the gauge/circle itself. Instead of the indicato ...

Tips for incorporating an outside model into vue.js with babylon js

Struggling with importing a gltf file into vue.js using babylon.js to create a 3D view on a webpage. The documentation online isn't very clear, and I've tried the following steps in my Hello.vue file: <div> <h1> Hello </h1> < ...

To change the font color to red when clicked, I must create a button using HTML, CSS, and Javascript

Currently, I am utilizing CodePen to assess my skills in creating a website. Specifically, I am focusing on the HTML component. My goal is to change the font color to blue for the phrase "Today is a beautiful sunny day!" Here is the snippet of code that I ...

Current selection in a dynamic menu within an Express universe

In my Express.js app, I am working on creating a simple menu. My goal is to add the "active" class to the menu list item of the page that is currently being visited. Here is the code snippet from my Jade view file: li(class = path === "/id/admin" ? "activ ...

Open Zurb Foundation Reveal Modal from the bottom of the screen

Struggling to make the reveal modal open from the bottom of the window. Any assistance would be highly appreciated. I've been attempting to tweak the open function with the reveal js, as seen in the original code below. Thank you, P open : function ...

Experiencing issues with your Jquery Slider?

An issue arises while utilizing the jquery slider in my aspx page that is associated with a master page. The error message received is: The state information is invalid for this page and might be corrupted. Description: An unhandled exception occurred du ...

The JSON.stringify function encounters difficulties when trying to format an object into

Why does JSON.stringify refuse to format objects and keep everything on a single line? <!DOCTYPE html> <html> <head> <script> var obj = { "a" : "1547645674576457645", "b" : "2790780987908790879087908790879087098", "c" ...

How do I execute a Next.js script that utilizes `fs` and `sharp` during development with Webpack?

I'm working on creating a basic GIFPlayer that displays a GIF when the play button is clicked, and shows a PNG otherwise: <img className="w-full h-full" src={isPlaying ? gifPath : imgPath} alt={pic.alt} /> Since I only have a GIF file ...

Update nested child object in React without changing the original state

Exploring the realms of react and redux, I stumbled upon an intriguing challenge - an object nested within an array of child objects, complete with their own arrays. const initialState = { sum: 0, denomGroups: [ { coins: [ ...

What are the limitations of sorting by price?

One issue I am facing is that the sorting functionality in the sortProductsByPrice (sortOrder) method doesn't work properly when products are deleted or added. Currently, sorting only applies to products that are already present in the this.products a ...

Discover how to transform a collection of numbers into a more expansive set that accurately reflects the original set

Consider an array with the following elements: [1,2,5,18,17,8]. Now, if you want to transform this array into a new one with a length of 40 while maintaining the same progression, you can use the following code: a = [1,2,5,18,17,8]; stepSize = 1 / (40 / ...