简体   繁体   中英

Sencha Touch: How to create a list in an hbox Panel

I have a navigation view, that contains a tabview, in which I would like to add an hbox panel that cotnains and list and another panel side by side. However when I try to add the list to the panel, nothing shows. I was wondering how it is possible to do this 在此处输入图片说明 Navigation View

Ext.define('MyApp.view.Navigation', {
    extend: 'Ext.navigation.View',
    id: 'NavView',
    xtype: 'navigationcard',
    onBackButtonTap: function () {
        //if on forms screen and button is visible remove add form button
        var self = Ext.getCmp('NavView');
        var naviBtn = Ext.getCmp('addNewFormBtn');
        if (naviBtn != null) {
            naviBtn.hide();
        }
        self.pop();
    },
    config: {
        title: 'Schedule',
        iconCls: 'settings',
        navigationBar: {
            items: [{
                xtype: 'button',
                text: 'Add New Form',
                align: 'right',
                id: 'addNewFormBtn',
                hidden: true,
                handler: function () {

            }
            }]
        },
        //we only give it one item by default, which will be the only item in the 'stack' when it loads
        items: [
                   {
                       xtype: 'mainview'
                   }
        ]
    }
});

Tab Panel

Ext.define('MyApp.view.Main', {
    extend: 'Ext.TabPanel',
    xtype: ['mainview', 'widget.mainview'],
    config: {
        title:'MyApp',
        fullscreen: true,
        tabBarPosition: 'bottom',
        defaults: {
            styleHtmlContent: true
        },
        items: [
            contain ,
            { xtype: 'settingscard' }
        ]
    }

});

Panel with Hbox and List

var testData = [];
for (var i = 0; i < 40; i++)
{ testData.push({ txt: "test" }); }

var storesdasd = Ext.create('Ext.data.Store', {
    data: testData
});

var contain = Ext.create('Ext.Panel', {
    fullscreen: true,
    layout: 'hbox',
    title: 'Schedules',
    iconCls: 'time',
    items: [{
        xtype: 'list',
        itemTpl: '{txt}',
        store: storesdasd,
        flex: 1,
        height: 'auto'
    }

    , {
        html: 'message preview',
        style: 'background-color: #759E60;',
        flex: 2,
        height: '100'
    }],
    config: {
        title: 'Schedules',
        iconCls: 'time'
    }
});

而不是将所有这些片段分开放在不同的文件中,我将它们放在Ext.application的启动功能中,尽管似乎不确定为什么,但这似乎已经奏效。

Use:

layout: {
    type: 'hbox',
    align: 'stretch'
}

Remove the height configs on the child items. Also remove the fullscreen config on the contain panel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM