Treeview ExtJS4树面板-更改没有子节点的节点的图标?

Treeview ExtJS4树面板-更改没有子节点的节点的图标?,treeview,extjs4,treepanel,Treeview,Extjs4,Treepanel,我在ExtJS4应用程序中有一个树面板,我想更改用于节点的图标,以便它们在不包含子节点时使用“叶”图标。但一旦添加了子节点,它就会恢复为正常文件夹图标。实现这一目标的最佳方法是什么?找到了答案: 在树面板初始化时,所有节点都有allowChildren:true和leaf:false,并且不包含子节点的节点都有iconCls:“tree-leaf”。该类附带的css规则为: .x-reset .tree-leaf, .x-reset .x-grid-tree-node-expanded .tre

我在ExtJS4应用程序中有一个树面板,我想更改用于节点的图标,以便它们在不包含子节点时使用“叶”图标。但一旦添加了子节点,它就会恢复为正常文件夹图标。实现这一目标的最佳方法是什么?

找到了答案:

在树面板初始化时,所有节点都有
allowChildren:true
leaf:false
,并且不包含子节点的节点都有
iconCls:“tree-leaf”
。该类附带的css规则为:

.x-reset .tree-leaf,
.x-reset .x-grid-tree-node-expanded .tree-leaf
{
    width: 16px;
    background-image: url('../ext4/resources/themes/images/gray/tree/leaf.gif');
}
然后,如果空节点中添加了任何子节点,我将通过以下方式以编程方式删除自定义iconCls css类:

node.set('iconCls', '');
当发生相反的情况时,当具有子节点的节点丢失其子节点且现在为空时,将通过编程方式向其添加自定义类:

node.set('iconCls', 'tree-leaf');
我想出来了:

在树面板初始化时,所有节点都有
allowChildren:true
leaf:false
,并且不包含子节点的节点都有
iconCls:“tree-leaf”
。该类附带的css规则为:

.x-reset .tree-leaf,
.x-reset .x-grid-tree-node-expanded .tree-leaf
{
    width: 16px;
    background-image: url('../ext4/resources/themes/images/gray/tree/leaf.gif');
}
然后,如果空节点中添加了任何子节点,我将通过以下方式以编程方式删除自定义iconCls css类:

node.set('iconCls', '');
当发生相反的情况时,当具有子节点的节点丢失其子节点且现在为空时,将通过编程方式向其添加自定义类:

node.set('iconCls', 'tree-leaf');

创建您自己的css表单并复制以下样式,这将覆盖默认样式并放置图像而不是主题

.x-tree-icon-leaf {
    background-color: transparent;
    width: 16px;
    height: 16px;
    background-image:url(../img/neogeo.png) !important;
}
.x-tree-icon-parent {
    background-color: transparent;
    width: 16px;
    height: 16px;
    background-image:url(../img/folder-pass.png) !important;
}
.x-tree-icon-parent-expanded {
    background-color: transparent;
    width: 16px;
    height: 16px;
    background-image:url(../img/folder-open-pass.png) !important;
}

创建您自己的css表单并复制以下样式,这将覆盖默认样式并放置图像而不是主题

.x-tree-icon-leaf {
    background-color: transparent;
    width: 16px;
    height: 16px;
    background-image:url(../img/neogeo.png) !important;
}
.x-tree-icon-parent {
    background-color: transparent;
    width: 16px;
    height: 16px;
    background-image:url(../img/folder-pass.png) !important;
}
.x-tree-icon-parent-expanded {
    background-color: transparent;
    width: 16px;
    height: 16px;
    background-image:url(../img/folder-open-pass.png) !important;
}

我不明白。添加子节点时,它不再“不包含子节点”。你是说你想让叶子图标永久化吗?我不明白。添加子节点时,它不再“不包含子节点”。那么,你是说你希望叶子图标是永久的吗?