I am using jsTree and so far it's looking good.
I have a list of nodes whose id gets incremented with every new node like(g1,g2,g3 ...and some other nodes like k1,k2,k3)
I can open a specific node on document load by using
"core": {
"animation": 0,
"open_parents": true,
"initially_open": ['g1']
},
But i want to open all the nodes that start with 'g' but not 'k' , is something like $(id^=g) can be used?
update:
The nodes are dynamically created through the web-service like
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
the data returned from the web-service is assigned to jstree,hence i need to open only the nodes with id that starts with 'g' and not 'k', in this above example there are just 2 nodes, but imagine if there are more than a 100 nodes.
The tree is called as so
$("#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);
}
}
};
}
}
});
Her only the node with id 'g1' opens whereas i want to open all the node starting with id 'g' is there a way to make it operational?