我正在使用jsTree,至今看起来不错。以特定字开头的开放式树节点
我有节点的ID被用像(G1,G2,G3 ......和像K1,K2,K3一些其他节点)
我可以打开一个特定节点的每个新节点递增列表通过使用
"core": {
"animation": 0,
"open_parents": true,
"initially_open": ['g1']
},
但我要打开与“G”,但不是“K”开头的所有节点文档加载, 是像$(ID^= G)可以用吗?
更新:
的节点通过web服务动态创建像
Dim oSB1 As StringBuilder = New StringBuilder
oSB1.Append(" <h5 >JSTree</h5> <div id='divtree' ><ul id='tree'> <li id='g1'><a href='#' class='usr'>1st Node</a><ul> <li><a href='#' rel='file'>1.1</a></li><li><a href='#' class='usr'>1.2</a></li><li><a href='#' class='file'>1.3</a></li></ul></li></ul><ul><li id='g2'><a href='#' class='usr'>2nd Node</a><ul> <li><a href='#' rel='file'>2.1</a></li><li><a href='#' >2.2</a></li></ul></ul> <ul><li id='k2'><a href='#' class='usr'>3rd Node</a><ul> <li><a href='#' rel='file'>3.1</a></li><li><a href='#' >3.2</a></li></ul></ul> <ul><li id='k2'><a href='#' class='usr'>4th Node</a><ul> <li><a href='#' rel='file'>4.1</a></li><li><a href='#' >4.2</a></li></ul></ul></div>")
Return oSB1.ToString
从web服务返回的数据被分配给jstree,因此我需要仅打开以'g'开始并且不以'k'开头的节点,在上面的例子中只有2个节点,但想象一下如果有多于100个节点。
的树被称为所以
$("#G2").html(data.d);
$("#divtree").jstree(
{
"state": "open",
"animated": "slow",
"plugins": ["themes", "html_data", "ui", "crrm", "contextmenu"],
//working
"core": {
"animation": 0,
"open_parents": true,
"initially_open": ['g1']
},
"contextmenu": {
"items": function ($node) {
return {
"Create": {
"label": "Create a new Node",
"action": function (obj) {
$("#divtree").jstree("create_node", function() { alert("are you sure?") }, true);
this.create(obj);
}
},
"Rename": {
"label": "Rename Node",
"action": function (obj) {
$("#divtree").jstree("rename_node", function() { alert("you are trying to rename") }, true);
this.rename(obj);
}
},
"Delete": {
"label": "Delete Node",
"action": function (obj) {
$("#divtree").jstree("delete_node", function() { alert("Really!!?") }, true);
this.remove(obj);
}
}
};
}
}
});
她唯一的ID为“G1”节点打开,而我想打开所有的节点开始ID为“G” 是有办法让它运行?
我仍然不知道如何自定义,根据我的需要:( – jeev 2013-02-18 10:48:58