将表格插入< li>当使用jsTree& JSON [英] insert table into <li> when using jsTree & json
问题描述
使用
- 时,我可以以某种方式在
- jsTree(1.0)和
- json?
< li>
内插入表 > 在此代码中,我想为
为什么?
$ b
data:[
{
data:A node,
children:[Child 1,Child 2]
},
{
attr:{ ID:li.node.id},
data:{
title:长格式演示,
attr:{href: }
}
}
]
更新: p>
在我看来,我可以使用 html_titles
。但有人可以给我一个例子,如何插入整个表格,并从变量中获取单元格数据?
Update2:
是否使用
data:< table>< tr>< td>网站名称< / td> ;< td>变量1< / td>< td>变量2< / td>< / tr>< / table>,
或
title:< table>< tr> < td>变量1< / td>< td>变量2< / td>< / tr>< / table",
< / code>
表格放在新行上。不是旁边的树形图标。我可以修正这个问题吗?
在原始文章中进行扩展以帮助其他人试图做到这一点:
$(function(){
$(#demo1)。jstree({
json_data:{
data:[
{
data:< table style ='display:inline-block'>< tr>< td>网站名称< / td> < td>变量1< / td>< td>变量2< / td>< / tr>< / table> ;,
children:[Child 1,Child 2 ]
$ {
attr:{id:li.node.id},
data:{
title :长格式演示,
attr:{href:#}
}
}
]
},
核心:{html_titles:true},
插件:[themes,json_data]
});
});
关键是允许在核心选项中设置的标题以及表格样式中的HTML
Can I somehow insert a table inside <li>
when using
- jsTree (1.0) and
- json?
let's say in this code where I want to insert table for
- both node and
- leaf.
Why? To display more things than only a name and using nice formatting.
"data" : [
{
"data" : "A node",
"children" : [ "Child 1", "Child 2" ]
},
{
"attr" : { "id" : "li.node.id" },
"data" : {
"title" : "Long format demo",
"attr" : { "href" : "#" }
}
}
]
update:
it seems to me that I can use html_titles
. But could somebody give me an example how to insert whole table and get cell data from variables?
Update2:
whether I use
"data" : "<table><tr><td>Site name</td><td>variable 1</td><td>variable 2</td></tr></table>",
or
"title" : "<table><tr><td>Site name</td><td>variable 1</td><td>variable 2</td></tr></table",
the table is placed on a new line. Not next to the tree icon. Can I fix that somehow?
Expanding on the original post to help others trying to do the same:
$(function () {
$("#demo1").jstree({
"json_data" : {
"data" : [
{
"data" : "<table style='display: inline-block'><tr><td>Site name</td><td>variable 1</td><td>variable 2</td></tr></table>",
"children" : [ "Child 1", "Child 2" ]
},
{
"attr" : { "id" : "li.node.id" },
"data" : {
"title" : "Long format demo",
"attr" : { "href" : "#" }
}
}
]
},
"core" : {"html_titles" : true},
"plugins" : [ "themes", "json_data" ]
});
});
The key is to allow html in the titles which is set in the core options as well as the table style
这篇关于将表格插入< li>当使用jsTree& JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!