【问题标题】:How can I access a menu in a panel's tbar in ExtJS?如何在 ExtJS 的面板的 tbar 中访问菜单?
【发布时间】:2011-03-28 19:50:43
【问题描述】:

我有一个 Ext.Panel 类型的 mediaGrid。该面板包含一个 tbar 和一个按钮组项,其中包含一个带有复选框的菜单。我需要能够从 mediaGrid 声明之外访问检查了哪些框,但我不知道该怎么做。这是 mediaGrid 声明:

var mediaGrid = new Ext.Panel({
    id: 'mediaviewer',
    region: 'center',
    border: false,
    items: mediaDataView,
    style: 'border-left: 1px solid #d0d0d0',

    tbar: [
        {
            xtype: 'buttongroup',
            title: 'Filters',
            items: [
                {
                    text: 'Show',
                    icon: '/img/picture.png',
                    iconAlign: 'top',
                    menu: {
                        xtype: 'menu',
                        defaults: {
                            hideOnClick: false,
                            listeners: {
                                checkchange: function (checkitem) {
                                    var menu = checkitem.ownerCt;
                                    var values = [];

                                    if (menu.pictureCheck.checked) {
                                        values.push('picture');
                                    }
                                    if (menu.videoCheck.checked) {
                                        values.push('video');
                                    }
                                    if (menu.noteCheck.checked) {
                                        values.push('note');
                                    }

                                    if (values.length == 0) {
                                        values.push('none');
                                    }

                                    mediaStore.reload({ params: { type: values.toString()} });
                                }
                            }
                        },

                        items: [
                            {
                                text: 'Pictures',
                                checked: true,
                                ref: 'pictureCheck'
                            },
                            {
                                text: 'Videos',
                                checked: true,
                                ref: 'videoCheck'
                            },
                            {
                                text: 'Notes',
                                checked: true,
                                ref: 'noteCheck'
                            }
                        ]
                    }
                }

            ]
        },
        '->',
        {
            xtype: 'searchfield',
            store: mediaStore,
            emptyText: 'Search',
            enableKeyEvents: true,
            listeners: {
                keyup: {
                    fn: function (thisField, e) {
                        if (!e.isNavKeyPress() && thisField.isValid()) {
                            thisField.onTrigger2Click();
                        }
                    },
                    buffer: 500
                }
            }
        },
        ' ',
        ' '
    ]
});

我在另一个面板上有一个按钮,单击该按钮会打开一个 Ext.Window 以将新节点添加到媒体 GridPanel。当用户单击“保存”时,它应该将注释添加到 GridPanel,但它还应该检查菜单以查看用于显示注释的过滤器是否已打开。这就是我需要访问菜单的原因。有谁知道如何访问 mediaGrid 中的菜单?

【问题讨论】:

    标签: asp.net-mvc-3 extjs menu tbar


    【解决方案1】:

    您始终可以在面板之外创建对象,然后将它们包含在面板中。这将允许您在任何您喜欢的地方引用它们。

    例如:

    var menu = new Ext.menu.Menu({
        //your menu configuration
    });
    
    var tbar = new Ext.Toolbar({
        //your toolbar configuration
        //...
        items: [menu] //and so on
    });
    
    var mediaGrid = new Ext.Panel({
        //your mediagrid configuration
        tbar: tbar
    });
    

    【讨论】:

      【解决方案2】:

      你也可以给tbar和ID...然后你可以尝试使用Ext.getCmp();

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-11
        • 1970-01-01
        • 1970-01-01
        • 2013-09-24
        • 2014-08-10
        • 1970-01-01
        • 2012-06-30
        • 1970-01-01
        相关资源
        最近更新 更多