jstree 中的不同树视图图标和 enable/disable 复选框
different tree view icons and enable/disable checkboxes in jstree
我需要更改树视图图标和 enable/disable 复选框
请查看以下代码:
function LoadJSTree() {
$.noConflict();
$(function () {
$('#demoTree').jstree({
'checkbox': {
'keep_selected_style': false,
'two_state': true
},
"types": {
"#": {
"max_children": 1,
"max_depth": 4,
"valid_children": ["root"]
},
"root": {
"icon": "/static/3.1.1/assets/images/tree_icon.png",
"valid_children": ["default"],
"check_node": false,
},
"default": {
"valid_children": ["default", "file"],
"check_node": true,
"uncheck_node": true
},
"disabled":{
"check_node": false,
"uncheck_node": false
},
"file": {
"icon": "glyphicon glyphicon-file",
"valid_children": [],
"check_node": true,
"uncheck_node": true
}
},
"plugins": ["types"],
'core': {
'data': [
{
"text": "Root node", "type": "root", "parent":"#", "children": [
{ "text": "Child node 1", "type": "default" },
{ "text": "Child node 2", "type": "default" },
{ "text": "Child node 3", "type": "default" },
{ "text": "Child node 4", "type": "default" },
{ "text": "Child node 5", "type": "default" },
{ "text": "Child node 6", "type": "default" },
{ "text": "Child node 7", "type": "default" },
{ "text": "Child node 8", "type": "default" }
]
}
],
},
'plugins': ["checkbox"]
});
好像不行。
每个节点都使用相同的文件夹图标显示树,并且每个节点始终存在复选框,难道不应该为 "root" 节点禁用它吗?
你能告诉我有什么问题吗?
您在配置中列出了 plugins
两次:
"plugins": ["types"],
...
'plugins': ["checkbox"]
将其更改为单个条目:
"plugins": ["checkbox", "types"]
但是请记住,没有选项(在 v.3 中,如果您使用的是该版本)来阻止基于节点类型的操作。但是使用最新的 jsTree 提交,您可以使用节点的 state
属性 在每个节点的基础上禁用复选框(您也可以禁用整个节点) - 如果这是您需要的看看这里:
我需要更改树视图图标和 enable/disable 复选框
请查看以下代码:
function LoadJSTree() {
$.noConflict();
$(function () {
$('#demoTree').jstree({
'checkbox': {
'keep_selected_style': false,
'two_state': true
},
"types": {
"#": {
"max_children": 1,
"max_depth": 4,
"valid_children": ["root"]
},
"root": {
"icon": "/static/3.1.1/assets/images/tree_icon.png",
"valid_children": ["default"],
"check_node": false,
},
"default": {
"valid_children": ["default", "file"],
"check_node": true,
"uncheck_node": true
},
"disabled":{
"check_node": false,
"uncheck_node": false
},
"file": {
"icon": "glyphicon glyphicon-file",
"valid_children": [],
"check_node": true,
"uncheck_node": true
}
},
"plugins": ["types"],
'core': {
'data': [
{
"text": "Root node", "type": "root", "parent":"#", "children": [
{ "text": "Child node 1", "type": "default" },
{ "text": "Child node 2", "type": "default" },
{ "text": "Child node 3", "type": "default" },
{ "text": "Child node 4", "type": "default" },
{ "text": "Child node 5", "type": "default" },
{ "text": "Child node 6", "type": "default" },
{ "text": "Child node 7", "type": "default" },
{ "text": "Child node 8", "type": "default" }
]
}
],
},
'plugins': ["checkbox"]
});
好像不行。
每个节点都使用相同的文件夹图标显示树,并且每个节点始终存在复选框,难道不应该为 "root" 节点禁用它吗? 你能告诉我有什么问题吗?
您在配置中列出了 plugins
两次:
"plugins": ["types"],
...
'plugins': ["checkbox"]
将其更改为单个条目:
"plugins": ["checkbox", "types"]
但是请记住,没有选项(在 v.3 中,如果您使用的是该版本)来阻止基于节点类型的操作。但是使用最新的 jsTree 提交,您可以使用节点的 state
属性 在每个节点的基础上禁用复选框(您也可以禁用整个节点) - 如果这是您需要的看看这里: