jqgrid 树网格单元格内是否可以有 html
我有一个 jqgrid 树网格单元格,我希望单元格内有包含链接和其他 html 格式的内容。
jqgrid treegrid 可以做到这一点吗?我没有看到文档中提到任何内容
i have a jqgrid treegrid cell and i want to have content inside of a cell that has links and other html formatting.
is this possible with jqgrid treegrid ? I don't see anything mentioned in the documentation
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您从 jqGrid 中了解到的大部分简单表数据对于树形网格仍然有效。因此,您可以使用自定义格式化程序或自定义属性格式化程序 (
cellattr
) 将 HTML 放入单元格中。如果需要,您可以将 HTML 片段放置在 JSON 或 XML 输入中。看看小演示:
重要的是要了解,树形网格不支持数据分页,因此您应该设置
rowNum
参数到足够大的值,例如 10000。我建议您检查树网格包含。您将看到隐藏列
'level'
、'parent'
、'isLeaf'
、'expanded'
、< code>'loaded' 和'icon'
作为最后一个网格列。此外,您将看到所有树节点(展开的和未展开的)都已添加到网格中。尚未展开的节点只是被隐藏。演示中使用的树形网格的代码
为
'AdjacencyTreeWithHTML.json'
:The most things which you know from jqGrid having simple table data still valid for the tree grid. So you can use custom formatters or custom attribute formatter (
cellattr
) to place HTML in the cells. You can place HTML fragments in the JSON or XML input if needed.Look at the small demo:
It is only important to understand, that the tree grid don't support data paging, so you should set
rowNum
parameter to the large enough value like 10000.I recommend you to examine the tree grid contain. You will see hidden columns
'level'
,'parent'
,'isLeaf'
,'expanded'
,'loaded'
and'icon'
as the last grid columns. Moreover you will see that all tree nodes (expanded and not expanded) are already added to the grid. Not yet expanded nodes are just hidden.The code of the tree grid used in the demo is
where
'AdjacencyTreeWithHTML.json'
:实现此目的的更好方法是使用自定义格式化程序,只需编写一个简单的函数来添加所需的 HTML,如下所示:
并将其链接到 colmodel 中的单元格,如参考链接中所述
:
http://www.trirand.com/jqgridwiki/doku.php?id =wiki:custom_formatter
A better way to achieve this is by using the custom formatter, just write a simple function which adds the HTML you need, like this:
and link it to the cell in the colmodel, as explained in the reference
link to reference:
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter
查看它生成的 HTML 源代码。如果它只是一个
对象(我怀疑它是),那么您可以在其中放置任何您想要的 HTML。
Look at the HTML source that it generates. If it is just a
<table>
object, which I suspect it is, then you can put whatever HTML you want in there.