Sencha Touch:TabPanel 内的工具栏

发布于 2024-12-08 13:46:04 字数 1009 浏览 3 评论 0原文

我是 Sencha Touch 的新手,只是想将工具栏放在 TabPanel 中。 我这样做是因为 TabPanel 将成为我的主要导航,而工具栏将提供一些与内容相关的操作,例如创建新的作业或类似的操作。

这是我的“解决方案”,但根本行不通。 TabPanel 会出现,“Hello World”也会出现,但不会有任何工具栏。

var tapHandler = function(btn, evt) {
alert("Button "+btn.text+" tapped");
}

var HomeScreen = new Ext.Panel({
fullscreen: true,
dockedItems: [
    {
        xtype: "toolbar",
        title: "buttons",
        ui: "light",
        dock: "bottom",
        items: [
            {ui: "action", text: "Add"}
        ],
        defaults: {
            handler: tapHandler
        }
    }
],
html: "Hello World"
});

new Ext.Application({
name: "Hello World",

launch: function() {
    var tabPanel = new Ext.TabPanel({
        fullscreen: true,
        ui: 'dark',
        sortable: true,
        items: [
            {
                title: "Home",
                html: "Loading..."
            }
        ]
    });
    tabPanel.items.get(0).update(HomeScreen, true);
}
});

你有什么解决办法吗?

问候, 马丁

I'm new to Sencha Touch and just trying to put a Toolbar inside of a TabPanel.
I do that because the TabPanel will be my main navigation and the Toolbar will provide several content-related operations, such as creating a new homework or sth like that.

Here is my "solution", that crtly doesn't work. The TabPanel appears, and the "Hello World" do so, too, but there won't be any Toolbar.

var tapHandler = function(btn, evt) {
alert("Button "+btn.text+" tapped");
}

var HomeScreen = new Ext.Panel({
fullscreen: true,
dockedItems: [
    {
        xtype: "toolbar",
        title: "buttons",
        ui: "light",
        dock: "bottom",
        items: [
            {ui: "action", text: "Add"}
        ],
        defaults: {
            handler: tapHandler
        }
    }
],
html: "Hello World"
});

new Ext.Application({
name: "Hello World",

launch: function() {
    var tabPanel = new Ext.TabPanel({
        fullscreen: true,
        ui: 'dark',
        sortable: true,
        items: [
            {
                title: "Home",
                html: "Loading..."
            }
        ]
    });
    tabPanel.items.get(0).update(HomeScreen, true);
}
});

Do you have any solutions?

Greetings,
Martin

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

魄砕の薆 2024-12-15 13:46:04

我认为这里的问题很可能是 update() 方法需要一个 HTML 字符串,而 HomeScreen 是一个 Ext.Panel。

如果是我,我会通过使用如下变量将 HomeScreen 添加到 tabPanel 中的 items 集合中:

    items: [
         HomePanel                              
    ]

或者通过在 items 数组中将其定义为对象:

items: [{
    xtype: "panel",
    html: "Hello world",
    dockedItems: [{
        // You toolbar definition
    }]
}]

或者通过使用 TabPanel.add() 方法:

tabPanel.add(HomePanel);

I think the problem here may well be that the update() method expects an HTML string and HomeScreen is an Ext.Panel.

If it were me, I'd be adding HomeScreen to the items collection in tabPanel either by using the variable like this:

    items: [
         HomePanel                              
    ]

Or by defining it inside the items array as an object:

items: [{
    xtype: "panel",
    html: "Hello world",
    dockedItems: [{
        // You toolbar definition
    }]
}]

Or by using the TabPanel.add() method:

tabPanel.add(HomePanel);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文