Yes, it is possible, in fact it is quite simple with jstree.
What you want to do is use the ajax
parameter of the json_data
plugin, but configure it so that either the data
parameter or url
passed a function that will send which node id is expanded so that your web service can make a call to your stored procedure and return data for children of the selected node.
Here, one example from http://www.jstree.com/documentation/json_data has changed a bit:
$("#tree").jstree({ "json_data" : { "ajax" : { "url" : "/yourwebservice/getnodechildren", "data" : function (node) { //this is passed the node being opened //or -1 if it the root node var dataToPass = {}; if (node === -1) { //pass parameters to the webservice that will build and return //first two tree levels dataToPass = { id : 0, initialLoad: true }; } if (node.attr && node.attr("id") { dataToPass = { id: node.attr("id"), initialLoad: false } } return dataToPass; }, "success" : function (dataFromWebservice) { //depending on how the webservice returns //data you may need to do this return dataFromWebservice.d; } } }, "plugins" : [ "themes", "json_data" ] });
You can make this code a little more elegant, but that's the point. This will allow you to build the tree on demand in pieces, and not immediately.
If your web service is configured in such a way that the parameters are passed to the URL, just make the url function instead and use this to create your url request with the node identifier or any other parameters you need.
source share