为什么itemselector中的按钮没有图标?

时间:2015-04-11 17:06:50

标签: icons extjs5 itemselector

我正在尝试使用Ext.ux.form.ItemSelector,但添加/删除/顶部/向下按钮上没有图标! 代码如下:

Ext.create('Ext.ux.form.ItemSelector', {
        renderTo: Ext.getBody(),
        name: 'channelRange',
        store: Ext.create('Ext.data.Store', {
            fields: ['display', 'value'],
            data: [{
                display: '22',
                value: 2
            }, {
                display: '33',
                value: 3
            }]
        }),
        buttons: ['add', 'remove'],//No icons on the buttons! Why?
        //imagePath: '../ux/images/',
        displayField: 'display',
        valueField: 'value',
        value : [ 3 ],
        allowBlank: false
    });

查看结果here,2 multiselect之间的按钮没有图标!

2 个答案:

答案 0 :(得分:2)

是的,这是ItemSelector的一个问题。在任何类型的BUILD之后,你都不会在按钮上看到任何图标。

我能够通过覆盖CSS来永久解决此问题。实际上,如果你调试代码,你会发现它正试图将这些按钮图标放在不同的位置。

// Do these overrides in any of your CSS file.
.x-form-itemselector-top {
    background-image: url(images/itemselector/top.gif) !important;
}
.x-form-itemselector-up {
    background-image: url(images/itemselector/up.gif) !important;
}
.x-form-itemselector-add {
    background-image: url(images/itemselector/right.gif) !important;
}
.x-form-itemselector-remove {
    background-image: url(images/itemselector/left.gif) !important;
}
.x-form-itemselector-down {
    background-image: url(images/itemselector/down.gif) !important;
}
.x-form-itemselector-bottom {
    background-image: url(images/itemselector/bottom.gif) !important;
}

注意:还要确保在给定路径(images/itemselector/)上有这些图标。在我的情况下,我将这些图标从"ui-client\ext\packages\ux\classic\resources\images\itemselector"复制到"ui-client\resources\images\itemselector"。这里"ui-client"是我的应用程序根文件夹。

希望以上提供的信息会有所帮助。

答案 1 :(得分:0)

我项目的解决方案:

grid.tbar.push({
    itemId  : 'create',
    iconCls : 'iconAdd',
    text : 'Add'
}

并在一些.css文件中配置:

.iconAdd {background: url(/resources/img/action-add.png) no-repeat !important;}