2

jqGrid treegrid all rows have same font size. How to decrease font size of rows which does not have any children ? I tried to use Oleg great answer in How to make jqgrid treegrid first row text bold to use rowattr for this. I havent found a way how to dedect in rowattr that row does not have children.

I current specific case all leafs are in third level. So in this case it is possible to decrease font size for whole third level. How to find treegrid nesting level in rowattr ?

Treegrid is defined as

        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;
            }
        }
      );
Community
  • 1
  • 1
Andrus
  • 26,339
  • 60
  • 204
  • 378
  • I have never used treegrid, from the sample provided by Oleg it seems to be that in grid data there is a item isLeaf. I think you have to check for rd.isLeaf See the demo here http://www.ok-soft-gmbh.com/jqGrid/LocalAdjacencyTree14.htm the data used there is (first row) {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"}, – Kris Mar 23 '13 at 10:10
  • @Krisl: If one search on stackoverflow the text of comments will be ignored. So it will be better if you write your suggestion as an answer and Andrus will "accept" it. In the way one will get other visitors more information. – Oleg Mar 24 '13 at 12:12
  • @Oleg, I hesitated to post it as answer because of 2 reasons, 1. I have never used treegrid, 2. The answer was based on your post and sample. – Kris Mar 25 '13 at 03:38

1 Answers1

2

I have never used treegrid, from the sample provided by Oleg it seems to be that in grid data there is an item isLeaf. I think you have to check for rd.isLeaf See the demo here the data used there is (first row)

{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"},
Kris
  • 1,882
  • 1
  • 20
  • 23