ExtJS4树形面板图标问题

发布于 2024-11-24 04:25:15 字数 1467 浏览 1 评论 0原文

我们在应用程序中使用树面板。代码是:

var exStore = Ext.create('Ext.data.TreeStore',{ 
    root : { 
        children : [{ 
            text : 'Parent 1',
            id : 'parent1',
            checked : false,
            iconCls : 'ico1',
            children : [{
                text : 'Child 1',
                id : 'child1',
                checked : false,
                leaf : true
            },{
                text : 'Child 2',
                id : 'child2',
                checked : false,
                leaf : true
            }]
        },{
            text : 'Parent 2', 
            id : 'parent2',
            checked : false,
            iconCls : 'ico2',
            children :[{
                text : 'Child 3',
                id : 'child3',
                checked : false,
                leaf : true
            },{
                text : 'Child 4',
                id : 'child4',
                checked : false,
                leaf : true
            }]
        }] 
    }
});

var treepanel = Ext.create('Ext.tree.Panel',{
    id : 'tree',
    width : 300,
    height : 300,
    store : exStore,
    rootVisible : false
});

但我们在这里面临两个问题。

1.我们为父节点指定了 iconCls。当树折叠时它显示正常。如果我们展开树,它会被文件夹图标替换。作为参考,请查看附图。
2.如果选择父节点,则必须选择特定父节点下的子节点。

在此处输入图像描述
在此处输入图像描述

如果有人有想法。请帮助我。我们在这些问题上做了很多尝试。

We are using treepanel in our application.The code is:

var exStore = Ext.create('Ext.data.TreeStore',{ 
    root : { 
        children : [{ 
            text : 'Parent 1',
            id : 'parent1',
            checked : false,
            iconCls : 'ico1',
            children : [{
                text : 'Child 1',
                id : 'child1',
                checked : false,
                leaf : true
            },{
                text : 'Child 2',
                id : 'child2',
                checked : false,
                leaf : true
            }]
        },{
            text : 'Parent 2', 
            id : 'parent2',
            checked : false,
            iconCls : 'ico2',
            children :[{
                text : 'Child 3',
                id : 'child3',
                checked : false,
                leaf : true
            },{
                text : 'Child 4',
                id : 'child4',
                checked : false,
                leaf : true
            }]
        }] 
    }
});

var treepanel = Ext.create('Ext.tree.Panel',{
    id : 'tree',
    width : 300,
    height : 300,
    store : exStore,
    rootVisible : false
});

But we are facing two issues here.

1.We have specified iconCls for parent node.It is displaying fine when tree collapsed.If we expand the tree it is replaced with folder icon.For reference please have a look at attached images.
2.If we select the parent node,then the child nodes under particular parent nodes has to getselected.

enter image description here
enter image description here

If any one has idea.Please help me.We are trying a lot on these issues.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

南…巷孤猫 2024-12-01 04:25:15

转到你的 css 并尝试类似的操作:

.x-tree-node-collapsed .x-tree-node-icon
{
    background-image: url('../images/tree/ico1.png') !important;
    background-repeat: no-repeat;
}

   .x-tree-node-expanded .x-tree-node-icon
{
    background-image: url('../images/tree/ico2.png') !important;
    background-repeat: no-repeat;
}
    .x-tree-node-leaf .x-tree-node-icon{
    background-image:url(/images/menu/folder.gif);

}

Go to your css and try something like :

.x-tree-node-collapsed .x-tree-node-icon
{
    background-image: url('../images/tree/ico1.png') !important;
    background-repeat: no-repeat;
}

   .x-tree-node-expanded .x-tree-node-icon
{
    background-image: url('../images/tree/ico2.png') !important;
    background-repeat: no-repeat;
}
    .x-tree-node-leaf .x-tree-node-icon{
    background-image:url(/images/menu/folder.gif);

}
魄砕の薆 2024-12-01 04:25:15

您可以通过列出树的“cls”属性来指定要应用图标更改的树。例如:

{    
    xtype: 'treepanel',    
    cls: 'my-tree-panel',    
    store: 'MyStore',
    ...
}  

这样,包含树面板的 DIV 将应用 CSS 类“my-tree-panel”。然后在您的 css 文件中定义选择器,如下所示:

.my-tree-panel .x-tree-icon-leaf {    
    background-image: url("images/newicon.png") !important;
}

图标更改将仅应用于该特定的树面板。因此,您可以在应用程序中拥有不同的树面板,并且可以为每个面板自定义图标。

You can specify which tree you want the icon change to apply by listing the 'cls' property of the tree. For example:

{    
    xtype: 'treepanel',    
    cls: 'my-tree-panel',    
    store: 'MyStore',
    ...
}  

With that, the DIV that contains the tree panel will have the CSS class 'my-tree-panel' applied to it. Then in your css file define the selector as follows:

.my-tree-panel .x-tree-icon-leaf {    
    background-image: url("images/newicon.png") !important;
}

The icon change will be applied only to that particular tree panel. Thus, you can have different tree panels in your applications and you'll be able to customize the icons for each.

迷爱 2024-12-01 04:25:15

更改树的图标,然后给出其 Id,就像

 #tree x-tree-node-expanded  .x-tree-node-icon
{
    background-image: url("bookopen.png") !important;
    background-repeat: no-repeat;
}
#tree .x-tree-node-collapsed   .x-tree-node-icon
{
    background-image: url("bookclose.png") !important;
    background-repeat: no-repeat;
}

您想要任何特定图标的图标,然后给出该节点 Id 一样,同样可以正常工作。

to change icon for tree then give its Id as

 #tree x-tree-node-expanded  .x-tree-node-icon
{
    background-image: url("bookopen.png") !important;
    background-repeat: no-repeat;
}
#tree .x-tree-node-collapsed   .x-tree-node-icon
{
    background-image: url("bookclose.png") !important;
    background-repeat: no-repeat;
}

if you want icon for any particular icon then give that node Id, the same works fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文