Can jqgrid tree grid show user-defined icon

微笑、不失礼 提交于 2019-12-24 07:32:02

问题


This first picture is result by using jqGrid tree grid. The icon is default set, non Leaf item is start with "Inverted triangle", Leaf item is start with "o".

How can I set to make the display result like the second picture,I can set different icon for each row?


回答1:


The input data of the TreeGrid can contain icon property with the class name, which specify the icon of the tree leaf. The value of node properties should contain two classes: one for expanded node and one more for collapsed node. For example

[
    { ...
        level: "0", parent: "null", isLeaf: false, expanded: true, loaded: true,
        icon: "ui-icon-folder-open,ui-icon-folder-collapsed" },
    { ...
        level: "1", parent: "1", isLeaf: true, expanded: false, loaded: true,
        icon: "ui-icon-flag" },
    { ...
        level: "2", parent: "2", isLeaf: true, expanded: false, loaded: true,
        icon: "ui-icon-star" },
    ...
]

The demo https://jsfiddle.net/OlegKi/4svafpub/3/ demonstrates the TreeGrid, which displays

You don't posted any details what you do. No version of jqGrid, which you use, no information about the fork of jqGrid (free jqGrid, commercial Guriddo jqGrid JS or an old jqGrid in version <=4.7). It's unknown which CSS framework you use: jQuery UI or Bootstrap and which icon set (jQuery UI icons, Font Awesome 4.x, glyph icons of Bootstrap ...). The exact implementation of your requirements will depends on the information. In any way you will have to choose the icons classes from the set of icons, which you use or you will need to define custom CSS classes, which you will use for TreeGrid nodes and leafs, and to define CSS rules, which specify all required CSS properties: background-image, background-position and so on. As the result you will be able to display any icon which you need.

UPDATED: It seems to me that icon will be used only for leafs, not for nodes as it is described above.

UPDATED 2: I made some changes in the code of free jqGrid and now one can specify the icons for the nodes of TreeGrid. The same code with updated version of free jqGrid displays

See the demo https://jsfiddle.net/OlegKi/4svafpub/4/



来源:https://stackoverflow.com/questions/44277526/can-jqgrid-tree-grid-show-user-defined-icon

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!