jsTree 上下文菜单不能与 jsTreeGrid 一起使用
jsTree contextmenu does not work along with jsTreeGrid
我是 jsTree 的新手。由于我需要同时表示节点类型和节点名称,因此我已转移到 jsTreeGrid。我需要创建节点、重命名、删除、编辑树节点以及编辑 jsTreeGrid 第二列中的节点类型。我可以以某种方式编辑第二列(即类型列),但 jsTree 仅显示上下文菜单,但未调用它们的相应函数。对此的帮助将非常有用。这是我的代码:
<div id="container"></div>
<script type="text/javascript">
$(document).ready(function(){
var data;
data = [{
text: "Satellite City",
data: {type: "<b>Project</b>", size: "30",spanclass:"root"},
children: [
{text: "Phase-1", data: {type: "<i>Phase</i>", size: "50",spanclass:"first"}},
{text: "Phase-2", data: {type: "<i>Phase</i>", size: "50",spanclass:"second"}, children:[
{text:"Ruby Towers",data:{type: "<i>Tower</i>",size:"50",spanclass:"third"}}
]}
]
}];
$("div#container").jstree({
plugins: ["themes", "json", "grid", "dnd", "contextmenu", "search"],
core: {
data: data
},
grid: {
columns: [
{width: 300, header: "WBS Tree",title:"_DATA_"},
{width: 100,
cellClass: "col1",
value: "type",
header: "<i>Node Type</i>",
valueClass:"spanclass"
},
],
resizable:true,
contextmenu:true
},
dnd: {
drop_finish : function () {
},
drag_finish : function () {
},
drag_check : function (data) {
return {
after : true,
before : true,
inside : true
};
}
}
});
$("input#search").keyup(function (e) {
var tree = $("div#container").jstree();
tree.search($(this).val());
});
});
</script>
我认为您的问题可能出在 jsTree 配置中。尝试将 "check_callback": true
添加到其 core
.
或检查工作 fiddle - JS Fiddle。
我是 jsTree 的新手。由于我需要同时表示节点类型和节点名称,因此我已转移到 jsTreeGrid。我需要创建节点、重命名、删除、编辑树节点以及编辑 jsTreeGrid 第二列中的节点类型。我可以以某种方式编辑第二列(即类型列),但 jsTree 仅显示上下文菜单,但未调用它们的相应函数。对此的帮助将非常有用。这是我的代码:
<div id="container"></div>
<script type="text/javascript">
$(document).ready(function(){
var data;
data = [{
text: "Satellite City",
data: {type: "<b>Project</b>", size: "30",spanclass:"root"},
children: [
{text: "Phase-1", data: {type: "<i>Phase</i>", size: "50",spanclass:"first"}},
{text: "Phase-2", data: {type: "<i>Phase</i>", size: "50",spanclass:"second"}, children:[
{text:"Ruby Towers",data:{type: "<i>Tower</i>",size:"50",spanclass:"third"}}
]}
]
}];
$("div#container").jstree({
plugins: ["themes", "json", "grid", "dnd", "contextmenu", "search"],
core: {
data: data
},
grid: {
columns: [
{width: 300, header: "WBS Tree",title:"_DATA_"},
{width: 100,
cellClass: "col1",
value: "type",
header: "<i>Node Type</i>",
valueClass:"spanclass"
},
],
resizable:true,
contextmenu:true
},
dnd: {
drop_finish : function () {
},
drag_finish : function () {
},
drag_check : function (data) {
return {
after : true,
before : true,
inside : true
};
}
}
});
$("input#search").keyup(function (e) {
var tree = $("div#container").jstree();
tree.search($(this).val());
});
});
</script>
我认为您的问题可能出在 jsTree 配置中。尝试将 "check_callback": true
添加到其 core
.
或检查工作 fiddle - JS Fiddle。