如何减少jqgrid treegrid叶子行中的字体大小

时间:2013-03-23 09:27:02

标签: javascript jquery-ui jqgrid

jqGrid treegrid所有行都有相同的字体大小。如何减少没有任何子节点的行的字体大小? 我尝试在How to make jqgrid treegrid first row text bold中使用Oleg很好的答案来使用rowattr。 我还没有找到一种方法如何在rowattr中确定该行没有子节点。

我目前的具体案例所有叶子都在第三级。因此,在这种情况下,可以减小整个第三级的字体大小。如何在rowattr中找到treegrid嵌套级别?

Treegrid定义为

        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;
            }
        }
      );

1 个答案:

答案 0 :(得分:2)

我从未使用过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"},
相关问题