在点击父节点(json)后加载子节点
Jstree - load child nodes after clicking on parent (json)
我想在单击父节点后加载父节点的子节点。因为有很多孩子,这是保持高性能的唯一方法。
现在我得到了这个
$(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"
}
}
});
});
相关文章:
- 如何在ReactJs中渲染子组件时重新加载子组件的数据
- AngularJS$stateProvider加载父模板,但不加载子模板
- 从父页重新加载子页
- 如何在 AngularJS 中重新加载子视图而不重新加载整个状态
- 检查是否使用茉莉花节点加载的节点模块
- 不修改加载的节点模块
- 加载子状态时修改父控制器状态
- 加载子页面的最佳方式?PHP或JS
- 在执行之前,请检查是否已加载子元素(图像)
- 剑道树,从多个节点开始,然后动态加载其余节点
- 冲突:加载子页时,JavaScript不起作用
- 如何静态加载子网格
- 从弹出窗口重新加载子域上的父窗口
- EmberJS加载子记录
- 在加载子网格表单时获取父属性
- 在登录后关闭子节点,并用登录数据重新加载父节点
- 在ajax调用中加载子元素的子元素
- Angular ui-router:如何加载子控制器而不是父控制器
- 随机加载子元素
- 在点击父节点(json)后加载子节点