jsTree 使用 JSON 数据绑定节点
编程代码以 C# 为例
JSON 模型
模型结构一
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
这种模型里的所有字段都可不填。
模型结构二
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
这种模型里的 id
和 parent
为必填。
注:
id
:节点的 id(不可以重复)text
:节点显示文本icon
:节点使用的图标children
:子节点opened
:节点是否展开
其他属性为验证。
jsTree将自动构建层次结构。要指示一个节点应该是根节点设置其parent
属性"#"
。
生成 Json
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
前端绑定
JS 绑定
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
注:
GetJsonUrl
:获取Json Url 地址或 Json 文件地址