jqGrid 树形网格的所有行都具有相同的字体大小。如何减小没有子项的行的字体大小? 我尝试在 How to make jqgrid treegrid first row text bold 中使用 Oleg 的精彩答案为此使用 rowattr 。 我还没有找到如何在 rowattr 中检测该行没有子项的方法。
我当前的具体情况所有叶子都处于第三级。因此,在这种情况下,可以减小整个第三级的字体大小。如何在 rowattr 中查找树形网格嵌套级别?
树形网格定义为
var treegrid = $("#tree-grid");
treegrid.jqGrid({
url: '/Store/GridData',
datatype: "json",
mtype: "POST",
height: "auto",
loadui: "disable",
treeGridModel: "adjacency",
colModel: [
{ name: "id", width: 1, hidden: true, key: true },
{ name: "menu", classes: "treegrid-column", label: "Product tree" },
{ name: "url", width: 1, hidden: true }
],
gridview: true,
rowattr: function (rd) {
// todo: decrease font size for leaf rows.
if (rd.parent === "-1" ) {
return {"class": "no-parent"};
}
},
autowidth: true,
treeGrid: true,
ExpandColumn: "menu",
rowNum: 2000,
ExpandColClick: true,
onSelectRow: function (rowid) {
var treedata = treegrid.jqGrid('getRowData', rowid);
window.location = treedata.url;
}
}
);
最佳答案
我从来没有使用过treegrid,从Oleg提供的样本来看,网格数据中似乎有一个项目isLeaf
。我想你必须检查rd.isLeaf
See the demo here那里使用的数据是(第一行)
{id: "1", name: "Cash", num: "100", debit: "400.00", credit: "250.00", balance: "150.00", enbl: "1", level: "0", parent: "null", isLeaf: false, expanded: true, loaded: true, icon: "ui-icon-carat-1-e,ui-icon-carat-1-s"},
关于javascript - 如何减小 jqgrid Treegrid 叶行中的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15585190/