【发布时间】:2017-03-21 09:17:31
【问题描述】:
我正在尝试将引导树用于 JSON 数据。我生成这样的 JSON 数据:
var newData = [
{
"resName": "LYS",
"atoms": [
{
"atomName": "N",
"x": 37.995,
"y": 20.521,
"z": 9.231
},
{
"atomName": "CA",
"x": 38.067,
"y": 19.342,
"z": 10.141
}
]
}
...
];
在代码的末尾,我希望得到这样的结果:
但http://jonmiles.github.io/bootstrap-treeview 代码使用这样的数据:
var defaultData = [
{
text: 'Parent 1',
href: '#parent1',
tags: ['4'],
nodes: [
{
text: 'Child 1',
href: '#child1',
tags: ['2'],
nodes: [
{
text: 'Grandchild 1',
href: '#grandchild1',
tags: ['0']
},
{
text: 'Grandchild 2',
href: '#grandchild2',
tags: ['0']
}
]
},
{
text: 'Child 2',
href: '#child2',
tags: ['0']
}
]
},
{
text: 'Parent 2',
href: '#parent2',
tags: ['0']
}
];
我可以使用 resName 或 atom 代替 text 吗?或者我可以做些什么来达到我的预期结果?我没有找到任何关于它的信息。
【问题讨论】:
标签: javascript json twitter-bootstrap treeview