Extjs 4.1 - 如何创建没有窗口或容器的tabpanel?

时间:2013-03-17 16:24:56

标签: javascript extjs extjs4

我想创建tabpanel,以便在我点击按钮时打开它。 我可以在窗口内创建它:

var window = new Ext.Window({
            id: 'item1',
            closable: true,
            floating: true,
            collapsible: true,
            width: 900,
            height: 600,
            autoScroll: true,
        items  : mytabpanel

}).show();

但我想知道如何在没有窗户的情况下做到这一点? 似乎show()不适用于tabpanel。

2 个答案:

答案 0 :(得分:1)

我不完全确定您要实现的目标,假设您创建选项卡面板的代码是正确的,那么我不明白为什么您的代码不起作用。

如果您不想在窗口中呈现选项卡面板,则可以始终使用renderTo属性将其呈现为实际的DOM元素。 e.g。

Ext.create('Ext.tab.Panel', {
            width: 400,
            height: 400,
            renderTo: document.getElementById('component'),
            items: [{
                title: 'Foo'
            }, {
                title: 'Bar',
                tabConfig: {
                    title: 'Custom Title',
                    tooltip: 'A button tooltip'
                }
            }]
        });

其中“component”是HTML页面中容器元素(例如DIV)的id。如果你在按钮的onclick事件中调用它,希望它应该做你需要的。

答案 1 :(得分:0)

如果您希望组件浮动,则应使用floating mixin