documentation for the TreeNode object列出名为expandable
的配置选项:
可扩展:布尔
如果设置为true,则节点将始终显示加号/减号图标,即使是 空
我通过以下方式创建了许多非叶子对象:
treeNodes[tag] = new Ext.tree.TreeNode({
text : tag,
leaf : false,
expanded : false,
expandable : true,
loaded : true
});
但是在将它们添加到根TreeNode之后,结果类似于:
这会让用户抱怨必须双击以展开节点。如何获得this example中的加/减按钮?
答案 0 :(得分:1)
您在此处粘贴的代码段没有错误。 TreePanel中可能有一些配置,您可能会在代码中添加这些配置可能会导致问题。可以配置' iconCls'
工作小提琴就在这里...... Plus and Minus in ExtJS tree
Ext.onReady(function() {
new Ext.tree.TreePanel({
title: 'Simple Tree',
width: 200,
height: 150,
rootVisible: false,
renderTo: Ext.getBody(),
root: {
expanded: true,
children: [{
text: "detention",
leaf: false,
expanded: false,
expandable: true,
loaded: true
}, {
text: "homework",
expanded: true,
children: [{
text: "book report",
leaf: true
}, {
text: "alegrbra",
leaf: true
}]
}, {
text: "buy lottery tickets",
leaf: true
}]
}
});
});
使用的版本是3.4.0。检查您的版本和代码。