煎茶触摸 2:在选项卡面板内创建嵌套列表

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

本文关键字:创建 列表 嵌套 选项 触摸      更新时间:2023-09-26

我已经尝试了一千种不同的方式来完成这项工作,Sencha Touch 文档远非清晰或有用,每个人似乎都以不同的方式做到这一点......这些都对我有用。

我设法让列表视图通过以下方式工作:

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
        }
    ]
}  
})

这是我进入导航视图的列表视图...在选项卡面板内。我使用导航视图的原因是,我可以从披露组件将产品详细信息视图推到顶部。

Ext.define("MyApp.view.ProductList", {
extend: 'Ext.List',
xtype: 'productlist',
requires: [
    'MyApp.store.ProductStore'
],
config: {
    itemTpl: '{text}', 
    store: 'ProductStore',
    onItemDisclosure: true 
}
}); 

这是我的模型:

Ext.define('MyApp.model.ProductListModel', {
extend: 'Ext.data.Model', 
config: {
    fields: ['text']
}
}); 

最后,这是我的存储,其中包含测试数据,目前没有嵌套:

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',
        },              
    ]
}
});

尝试添加

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
    }
}