我在最新版本1.2.4中有一个延迟加载DynaTree并获得challange,以提供当前所选节点的路径。 我在根节点上循环以构建树的第一级。单击其中一个根节点后,树将展开并通过延迟加载选择下一个元素。 现在树的第三维中的元素是已知的,但是我如何在JSON结构中提供受影响的节点? 对末尾的简单添加也将添加根树中的元素。
$(function(){
// Attach the dynatree widget to an existing <div id="tree"> element
// and pass the tree options as an argument to the dynatree() function:
$("##tree").dynatree({
clickFolderMode: 3,
persist: false,
autoCollapse: true,
onActivate: function(node) {
// A DynaTreeNode object is passed to the activation handler
// Note: we also get this event, if persistence is on, and the page is reloaded.
if( node.data.href ){
// use href and target attributes:
window.location.href = node.data.href;
}
},
onLazyRead: function(node){
node.appendAjax({url: "#intranetpath#remote/lopTreeLoader.cfc?method=getNodes",
data: {"key": node.data.key, // Optional url arguments
"mode": "all"
},
// (Optional) use JSONP to allow cross-site-requests
// (must be supported by the server):
// dataType: "jsonp",
success: function(node) {
// Called after nodes have been created and the waiting icon was removed.
// 'this' is the options for this Ajax request
},
error: function(node, XMLHttpRequest, textStatus, errorThrown) {
// Called on error, after error icon was created.
},
cache: false // Append random '_' argument to url to prevent caching.
});
},
children: [ // Pass an array of nodes.
<cfloop query="qDivision">
{ key:"#qDivision.obj_uuid#" ,
title: "#qDivision.f_division_name#",
activate:false,
expand:#qDivision.expand#,
select:false,
isLazy:true,
<cfif qDivision.clickable>
addClass:"boldText",
href: "/program.helios/lop/index.cfm?obj_uuid=#qDivision.obj_uuid#",
</cfif>
icon:"../../skin/icons/idivision.gif"}
<cfif qDivision.currentrow NEQ qDivision.recordcount>,</cfif>
</cfloop>
]
});
});
如何使用所选节点的直接路径中的所有节点初始化树?
答案 0 :(得分:0)
子对象可能反过来包含children
属性:
children: [ // Pass an array of nodes.
<cfloop query="qDivision">
{ key:"#qDivision.obj_uuid#" ,
title: "#qDivision.f_division_name#",
activate:false,
children: [{title: "foo"}, ...]