我在最新版本 1.2.4 中有一个延迟加载 DynaTree 并获得挑战,以提供当前选定节点的路径。我对根节点进行循环以构建树的第一级。单击其中一个根节点后,树会展开并通过延迟加载下一个元素进行选择。现在树的第三维中的元素是已知的,但是我如何在 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>
]
});
});
如何使用指向所选节点的直接路径中的所有节点初始化树?