我正在创建一个dynatree,它的节点选项expand = false。但是当我查看树时,它显示了所有在开始时的开销。如何在初始阶段获得所有崩溃的树。下面是我的代码
$(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;
});
},
});
});发布于 2013-02-28 16:17:12
在我的dynatree中,我在init上使用AJAX并展开整个树,但对代码的修改可能会对您有所帮助:
onPostInit: function(isReloading, isError) {
this.$tree.dynatree('getRoot').visit(function(node){
node.expand(false);
});
}https://stackoverflow.com/questions/15110953
复制相似问题