javascript EXTJS:设置可见后不显示隐藏元素

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11447014/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 13:15:25  来源:igfitidea点击:

EXTJS: hidden element does not show up after setvisible

javascripteventsextjsextjs4

提问by Javier Sanchez

Hello I want to show and image that is like an alert sign when a change is done, then I have a footer panel like this one, with the sign:

您好,我想在更改完成时显示类似于警报标志的图像,然后我有一个像这样的页脚面板,带有标志:

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);
    }
});

And the idea is that I have a general function which I could call anywhere and show or hide the icon, but unfortunately I call this function and nothing happens:

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

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);
    }
}

I tried by directly calling the component and setVisible(true) as well and nothing happens.

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

回答by Jom

get the footerPanel component and use hide/ show method.

获取 footerPanel 组件并使用隐藏/显示方法。

like

喜欢

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-hide

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

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