javascript - 如何减小 jqgrid Treegrid 叶行中的字体大小

标签 javascript jquery-ui jqgrid

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/

相关文章:

perl - 如何在 Catalyst 应用程序中公开多对多标签样式关系?

javascript - 在表中显示 json 数组

jquery - 如何针对不同屏幕宽度使用jqgrid卡住列?

javascript - 解释一下可滚动表格的代码

jquery - 如何使用 jQuery 在 HTML 中显示对话框?

javascript - Jquery表不显示

javascript - 在点击事件的正下方放置 jquery 对话框

javascript - 提供 AngularJS Controller 数据

javascript - Node js 使用 request/request api 调用返回的数据

javascript - 我如何通过外部javascript调用用reactjs编写的函数?