后处理的结果适用于以下情况:
return o && { title: o.combndName, key: o.parentSqn, folder: true , lazy: true};
但是,子元素的数据集本身没有标题和键,还需要映射到这些名称。
如何为延迟加载的子节点创建后处理?
function getTreeData() {
$.getScript('//cdn.jsdelivr.net/npm/jquery.fancytree@2.27/dist/jquery.fancytree-all-deps.min.js', function () {
$("#tree").fancytree({
source:
{
url: "/api/treetoplevel",
data : {}
},
postProcess: function (event, data) { // activate lazy loading.
data.result = $.map(data.response, function (o) {
return o && { title: o.combndName, key: o.parentSqn, folder: true , lazy: true};//transform to tree output. TODO: play with columns after.
});
},
activate: function(event, data){
var node = data.node;
alert(node.key)
},
lazyLoad: function(event, data) {
var node = data.node;
data.result = {
url: "/api/tree/" + node.key.toString(),
//url : "parent.json",
data: { mode: "children", parent: node.key },
cache: false
};
}
});
});
};