如何在 Extjs 中隐藏面板?

How to hide panel in Extjs?

美好的一天。

我有代码:

{
    xtype: 'panel',
    title: 'test panel',
    html:'test,
    visible: false// did not work
}

如何防止显示面板没有监听器和控制器?

使用 属性 hidden 代替:

{
    xtype: 'panel',
    title: 'test panel',
    html:'test',
    hidden: true // <<== Should works
}

hidden 配置通常不会应用于部分视图,只有 Sencha 知道原因。

但是,如果需要,您可以在部件的 createView 方法中使用一行代码来实现。以您的 fiddle 为例:

Ext.define('GAINS.parts.ConfigPart', {
    extend: 'Ext.dashboard.Part',
    alias: 'part.config-part',
    config: {
        hidden: false,
        viewTemplate: {
            layout: 'fit',
            mergin: 9
        }

    },
    createView: function (config) {
        var view = this.callParent(arguments);
        view.items = config.configPartItems;
        if(config.hidden) view.hidden = true; // apply the  "hidden" config to the view.
        return view;
    }
});