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?