Sencha Touch中的嵌套面板/工具栏

时间:2011-04-12 04:06:14

标签: javascript mobile sencha-touch extjs

我正在尝试创建一个恒定的底部工具栏,它控制着它上面的面板。然后它上面的面板应该有一个自己的工具栏(在顶部)。我尝试了下面的代码,几乎可以工作,但我看不到子页内部面板的html。我认为这是因为面板没有占用剩余高度,但我不知道为什么。

有人有什么想法吗?谢谢!

Ext.setup({
    onReady: function() {


    // Sub-page sections
    var blah = {
        style: "background-color: #B22222; color:#FF0000;",
        title: "one",
        html: "Why can't I see this html",
        layout:"fit",
        flex: 1
    };
    var blah2 = {
        style: "background-color: #404040; color:#000000;",
        title: "one",
        html: "Why can't I see this html",
        layout:"fit",
        flex: 1
    };  

    // Main portion of the page, which includes top toolbar and content
    var page1 = new Ext.TabPanel({
        dock: "bottom",
        layout: "card",
        items: [blah, blah2, blah],
        title: "one",
        flex: 1
    });

    // This is the outer panel with the bottom toolbar
    var wrapper = new Ext.Panel({
        fullscreen: true,
        items: page1,
        dockedItems: [
          {
            xtype: "toolbar",
            dock: "bottom",
            items: [
              {
                iconMask: true,
                iconCls: "download"
              },
              {
                iconMask: true,
                iconCls: "favorites"
              },
              {
                iconMask: true,
                iconCls: "search"
              },
              {
                iconMask: true,
                iconCls: "user"
              }
            ]  
          }
        ]
      });
    }
});

2 个答案:

答案 0 :(得分:8)

听起来你正在尝试做的事情可以使用TabPanel而不是工具栏来完成。将tabBar停靠在底部时,每个tabButton都可以接受一个图标。

我可能误解了你想要做的事情,但这应该有所帮助:

Ext.setup({
    onReady: function() {


        // Sub-page sections
        var blah = {
            style: "background-color: #B22222; color:#FF0000;",
            title: "one",
            html: "Why can't I see this html",
        };
        var blah2 = {
            style: "background-color: #404040; color:#000000;",
            title: "one",
            html: "Why can't I see this html",
        };  

        // Main portion of the page, which includes top toolbar and content
        var page1 = new Ext.TabPanel({
            items: [blah, blah2, blah],
            title: "one",
            iconMask: true,
            iconCls: "download",
        });

        // This is the outer panel with the bottom toolbar
        var wrapper = new Ext.TabPanel({
            fullscreen: true,
            tabBar: {
                dock: 'bottom',
                layout: {
                    pack: 'center'
                }
            },
            items: [
                page1,
                {
                    iconMask: true,
                    iconCls: "favorites"
                },
                {
                    iconMask: true,
                    iconCls: "search"
                },
                {
                    iconMask: true,
                    iconCls: "user"
                }
            ]
        });
    }
});

我制作了关于building a user interface in sencha touch using tabs and toolbars的截屏视频。有一个live democode is on github,所以请随意使用它作为参考。

答案 1 :(得分:1)

layout: "card",

out of page1 TabPanel,并将其放在包装器面板中