我正在使用NODE选项expand = false创建一个dynatree。但是当我查看树时,它显示了所有在开始时消耗的树。如何在初始阶段获得所有崩溃的树。 下面是我的代码
$(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({
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.
//alert("You activated " + node.data.key);
},
persist: false,
checkbox: true,
generateIds: false,
classNames: {
checkbox: "dynatree-checkbox",
expanded: "dynatree-expanded"
},
selectMode: 3,
children: {!JsonString},
onSelect: function(select, node) {
// Get a list of all selected nodes, and convert to a key array:
var selKeys = $.map(node.tree.getSelectedNodes(), function(node){
return node.data.key;
});
jQuery(document.getElementById("{!$Component.selectedKeys}")).val(selKeys.join(", "));
// Get a list of all selected TOP nodes
var selRootNodes = node.tree.getSelectedNodes(true);
// ... and convert to a key array:
var selRootKeys = $.map(selRootNodes, function(node){
return node.data.key;
});
},
});
});
答案 0 :(得分:1)
在我的dynatree中,我在init上使用AJAX并扩展整个树,但是我的代码修改可能对你有所帮助:
onPostInit: function(isReloading, isError) {
this.$tree.dynatree('getRoot').visit(function(node){
node.expand(false);
});
}