0

我正在尝试创建一个在选项卡旁边有一个文本标题的 TabPanel。也就是说,而不是

|Tab1|Tab2|Tab3|Tab4|, 我想Text Here |Tab1|Tab2|Tab3|Tab4|

文本不应该作为选项卡选择,那么我该怎么做呢?

目前,我的 TabPanel 是这样的:

new Ext.TabPanel({
    id: 'lift-template',
    defaults: {
        items:[
            {
                xtype: 'list',
                store: myStore,
                itemCls: 'my-row',
                itemTpl: '<p><span class="blah">{variable}</span></p>'
            }
        ]
    },
    items: [
        {title:'Week'},
        {title: '1'},
        {title: '2'},
        {title: '3'},
        {title: '4'}
    ]
});

如何添加不是真正选项卡的项目,或者至少禁用激活?

4

2 回答 2

2

我不会尝试使用选项卡的功能来破解标签。你想要的只是一个标签,所以你可能可以查看源代码TabPanel并找到一个方便的地方添加它。

我只是查看了Ext.TabPanel(Ext 3.3.1)的源代码,并且onRender是创建标签条的方法,所以我要做的是创建一个自定义扩展名Ext.TabPanel,调用它MyApp.WeeksTabPanel,并在调用后覆盖onRender添加标签的方法超类方法。看起来您可能只是添加一个自定义跨度作为this.stripWrap.

像这样的东西:

MyApp.WeeksTabPanel = Ext.extend(Ext.TabPanel, {

    onRender: function() {
        MyApp.WeeksTabPanel.superclass.onRender.apply(this, arguments);
        this.stripWrap.insertFirst({tag: 'span', html: 'Weeks:'});
    }

});
于 2011-10-25T19:40:23.470 回答
1

与 SeanA 提供的答案略有相似,这是 Sencha Touch (1.1) 的修改版。

查看示例

/**
 * We will just need to extend the original tabpanel to
 * have the ability to create extra text node in front
 * of all the tabs (Check Ext.TabBar)
 */
var FunkyTabPanel = Ext.extend(Ext.TabPanel, {
    initComponent: function() {

        //we need it to initialize the tab bar first
        FunkyTabPanel.superclass.initComponent.call(this);

        //Then we hack in our text node. You can add cls/style too
        this.tabBar.insert(0, {
            text: this.title,
            style: 'color:#fff;'
        });
    }
});
于 2011-10-26T07:13:02.300 回答