简体   繁体   中英

Sencha Touch 2: Creating a Nested List inside a tab panel

I've tried to accomplish this a thousand different ways now, the Sencha Touch documentation is far from clear or helpful, and everyone seems to do it a different way...none of which have worked for me.

I've managed to get a List view working in the following way:

Ext.define("MyApp_eComm.view.Products", {
extend: 'Ext.navigation.View', //Needs to be navigation view to display the     ProductList.js
xtype: 'products',

requires: [
    'Ext.dataview.List',
    'MyApp.view.ProductList',
    'MyApp_eComm.view.ProductDetail'
],

config: {
    title: sMY_CONST_TAB_BROWSE_TITLE,
    iconCls: sMY_CONST_TAB_BROWSE_CLASS,

    styleHtmlContent: true,
    scrollable: true,

    items: [ 
        /*{
            xtype: 'titlebar',
            docked: 'top',
            title: sMY_CONST_TAB_BROWSE_SUBTITLE
        },*/
        {
            xtype: 'productlist',
            title: sMY_CONST_TAB_BROWSE_SUBTITLE
        }
    ]
}  
})

This is my List view that goes inside the navigation view...inside the tab panel. the reason I've used a navigation view is so I can push a product details view on top from the disclosure component.

Ext.define("MyApp.view.ProductList", {
extend: 'Ext.List',
xtype: 'productlist',

requires: [
    'MyApp.store.ProductStore'
],

config: {
    itemTpl: '{text}', 
    store: 'ProductStore',
    onItemDisclosure: true 
}
}); 

Here is my model:

Ext.define('MyApp.model.ProductListModel', {
extend: 'Ext.data.Model', 

config: {
    fields: ['text']
}
}); 

And finally here is my store with test data in, not nested at the moment:

Ext.define('MyApp.store.ProductStore', {
extend: 'Ext.data.Store',

config: {
    model: 'MyApp.model.ProductListModel',
    sorters: 'text',
    data: [
        {
            text: 'Burgers',
        },
        {
            text: 'Pasta',
        },
        {
            text: 'Sausages',
        },
        {
            text: 'Cabbage',
        },
        {
            text: 'Lettuce',
        },
        {
            text: 'Marmalade',
        },
        {
            text: 'Honey',
        },
        {
            text: 'Yogurt',
        },
        {
            text: 'Cheese',
        },
        {
            text: 'Milk',
        },
        {
            text: 'Bread',
        },
        {
            text: 'Butter',
        },
        {
            text: 'Goats Milk',
        },
        {
            text: 'Apple',
        },
        {
            text: 'Oranges',
        },
        {
            text: 'Bananas',
        },
        {
            text: 'Jelly',
        },
        {
            text: 'Spagetti Hoops',
        },
        {
            text: 'Ravioli',
        },
        {
            text: 'Wheatabix',
        },
        {
            text: 'Cornflakes',
        },              

    ]
}
});

try to add so

config: {
  title: sMY_CONST_TAB_BROWSE_TITLE,
  iconCls: sMY_CONST_TAB_BROWSE_CLASS,

  styleHtmlContent: true,
  scrollable: true,

  items: 
    {
        xtype: 'productlist',
        title: sMY_CONST_TAB_BROWSE_SUBTITLE
    }

}  

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