简体   繁体   English

如何使用extjs在桌面/面板中显示隐藏的小部件?

[英]how to show hidden widget in desktop/panel with extjs?

i have a toolbar in my desktop. 我的桌面上有一个工具栏。 also i have a button on desktop for showing and hiding this toolbar. 我也有一个按钮在桌面上显示和隐藏此工具栏。 at the moment i have extra button for hiding in toolbar itself and its works ok. 目前,我还有其他按钮可以隐藏在工具栏本身中,并且可以正常工作。 if Iam hiding it, toolbar is completely initialized and panel1.object (see code below) looks like this: 如果Iam将其隐藏,则工具栏将完全初始化,panel1.object(请参见下面的代码)如下所示:

 activeUI: "default" autoGenId: true body: constructor collapseDirection: "top" componentCls: "x-panel" componentLayout: constructor componentLayoutCounter: 2 container: constructor dd: constructor dock: "top" dockedItems: constructor el: constructor events: Object floatingItems: constructor frame: undefined hasListeners: HasListeners height: 35 hidden: true hiddenByLayout: null hiddenOnCollapse: constructor hierarchyState: Object hierarchyStateInner: Object id: "TESTtoolbarX-1034" initialConfig: Object initialStyle: Object items: constructor lastBox: Object layout: constructor layoutCounter: 2 loader: null margin$: Object ownerCt: constructor ownerLayout: constructor plugins: undefined pluginsInitialized: true protoEl: null renderData: Object renderSelectors: Object rendered: true rendering: null scrollFlags: Object stateEvents: Array[0] stateId: undefined tools: Array[0] ui: "default" uiCls: Array[1] x: 0 y: 0 __proto__: Object 

if i'm trying to SHOW my toolbar with external button on the dekstop my panel1.object is much shorter. 如果我想用dekstop上的外部按钮显示我的工具栏,我的panel1.object会更短。

autoGenId: true
collapseDirection: "top"
componentCls: "x-panel"
componentLayout: constructor
dockedItems: constructor
events: Object
floatingItems: constructor
hasListeners: HasListeners
height: 35
hiddenOnCollapse: constructor
id: "TESTtoolbarX-1067"
initialConfig: Object
initialStyle: Object
items: constructor
layout: constructor
loader: null
plugins: undefined
pluginsInitialized: true
protoEl: constructor
renderData: Object
renderSelectors: Object
stateEvents: Array[0]
stateId: undefined
__proto__: Object

i'm trying to show it like this (Code from Controller): 我正在尝试显示它(来自控制器的代码):

 onShowToolbar: function() {
        debugger;

        var panel1 = Ext.create('TEST.view.desktop.Toolbar', { maxWidth: 360, height: 35 });
        panel1.show();},

how i can show this * toolbar right? 我如何才能显示此*工具栏正确? please help! 请帮忙!

Simple example. 简单的例子。 Panel with toolbar and button. 带有工具栏和按钮的面板。 Click on button show or hide toolbar. 单击按钮显示或隐藏工具栏。
View: 视图:

Ext.define('TEST.view.desktop.Desktop', {
    extend: 'Ext.panel.Panel',
    alias: 'widget.desktop.Desktop',

    initComponent: function () {
        var me = this;
        Ext.applyIf(me, {
            dockedItems: [
                {
                    xtype: 'toolbar',
                    hidden: true
                }
            ],
            items: [
                {
                    xtype: 'button',
                    action: 'testbutton'
                }
            ]
        });
        me.callParent(arguments);
    }
});


Controller: 控制器:

Ext.define('TEST.controller.desktop.Desktop', {
    extend: 'Ext.app.Controller',

    views: ['desktop.Desktop'],

    init: function () {
        this.control({
            '[xtype=desktop.Desktop] button[action=testbutton]': {
                click: this.showHideToolbar
            }
        });
    },

    showHideToolbar: function (button) {
        var tb = button.up('panel').down('toolbar');
        if (tb.isVisible()) {
            tb.hide();
        } else {
            tb.show();
        }
    }
});

UPDATE : Controller with mouse(over/out): 更新 :带有鼠标(上/下)的控制器:

Ext.define('TEST.controller.desktop.Desktop', {
    extend: 'Ext.app.Controller',

    views: ['desktop.Desktop'],

    init: function () {
        this.control({
            '[xtype=desktop.Desktop] button[action=testbutton]': {
                mouseover: this.showToolbar,
                mouseout: this.hideToolbar
            }
        });
    },

    showToolbar: function (button) {
        var tb = button.up('panel').down('toolbar');
        tb.show();
    },

    hideToolbar: function (button) {
        var tb = button.up('panel').down('toolbar');
        tb.hide();
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM