我想在单击父节点后加载父节点的子节点。因为有很多孩子,这是保持高性能的唯一方法。
现在我得到了这个
$(function () {
$.support.cors = true;
$('#using_json').jstree({
"plugins": ["themes", "json_data", "dnd", "wholerow"],
'core': {
'data': {
'url': "http://localhost:56311/ProductRESTService.svc/GetCountryList",
'dataType': "json"
}
}
});
});
对于第一级来说很好。现在我想从这个URL
获取子节点" http://localhost: 56311/ProductRESTService.svc/GetRegionList/{id}",
我不知道如何才能做到这一点?
编辑:服务GetCountryList生成了如下内容:
[{"id":"DE","parent":"#","state":"closed","text":"DE"},
{"id":"GBR","parent":"#","state":"closed","text":"GBR"},
{"id":"SE","parent":"#","state":"closed","text":"SE"}]
和GetRegionList
像这样:
[{"id":"SH","parent":"DE","state":"closed","text":"SH"},
{"id":"NRW","parent":"DE","state":"closed","text":"NRW"},
{"id":"LON","parent":"GBR","state":"closed","text":"LON"}]
使用
$(function () {
$.support.cors = true;
$('#using_json').jstree({
"plugins": ["themes", "json_data", "dnd", "wholerow"],
'core': {
'data': {
'url': function (node) {
if(node.id === '#') {
return "http://localhost:56311/ProductRESTService.svc/GetCountryList";
}
else {
return "http://localhost:56311/ProductRESTService.svc/GetRegionList/" + node.id;
}
},
'dataType': "json"
}
}
});
});