EXTJS:隐藏元素在setvisible后不显示

问题描述 投票:1回答:1

您好我想要在更改完成后显示和图像就像一个警告标志,然后我有一个像这样的页脚面板,标志:

Ext.define('footerPanel', {
    extend: 'Ext.panel.Panel',
    cls: 'fastec_background',
    height: 24,
    autoScroll: false,
    border: false,
    layout: {
        type: 'border'
    },
    id: 'panel_footerFastec',


    initComponent: function () {
        var me = this;


        Ext.applyIf(me, {
            items: [{
                margin: '5 5 0 20',
                xtype: 'label',
                region: 'center',
                html: '<a>© 2012 FASTEC GmbH, Paderborn, Germany - </a><a target="_blank" href="http://www.easyoee.de">www.easyOEE.de</a> <a target="_blank" href="http://www.fastec.de">www.fastec.de</a>'
            }, {
                xtype: 'container',
                region: 'east',
                layout: 'table',
                id: 'cont_footer_icons',
                items: [{
                    xtype: 'image',
                    id: 'configchangedIcon',
                    height: 16,
                    margin: '5 0 5 0',
                    width: 16,
                    maxHeight: 20,
                    dock: 'right',
                    maxWidth: 20,
                    scale: 'large',
                    src: 'files/images/disk_blue.png',
                    hidden: true
                }, {
                    xtype: 'image',
                    height: 16,
                    id: 'errorIcon',
                    margin: '5 0 5 0',
                    width: 16,
                    dock: 'right',
                    maxHeight: 20,
                    maxWidth: 20,
                    scale: 'large',
                    src: 'files/images/error16.gif',
                    hidden: true
                }]
            }]
        });


        me.callParent(arguments);
    }
});

我的想法是,我有一个通用功能,我可以在任何地方调用并显示或隐藏图标,但不幸的是我调用此函数,没有任何反应:

changeIconVisibility = function(str, value) {
    try {
        switch(str){
            case 'configchangedIcon':
                var img = Ext.getCmp('configchangedIcon');
                if(value){
                    img.setVisible(true);
                }else{
                    img.setVisible(false);
                }
            break;
        }
    } catch (e) {
        Ext.msg.alert(e);
    }
}

我尝试直接调用组件和setVisible(true)也没有任何反应。

javascript events extjs extjs4
1个回答
0
投票

获取footerPanel组件并使用hide / show方法。

喜欢

var myPanel = Ext.getCmp('your_panel');
myPanel.items.items[1].hide() //second  item

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.panel.Panel-method-hide

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.panel.Panel-method-show

© www.soinside.com 2019 - 2024. All rights reserved.