我的tabBar上的嵌套列表不起作用

时间:2012-12-10 14:46:58

标签: load sencha-touch nested-lists

我是senbe的新手,只是尝试学习组件 - 在我遇到嵌套列表之前没事。数据未加载到我的嵌套列表中。但为什么?来自网站的代码不起作用,所以我尝试在控制器中添加组件 - 容器和嵌套列表,但它也不起作用。 查看

   Ext.define('MyFirstApp.view.MainView', {
    extend: 'Ext.TabPanel',
    requires: ['Ext.Button'],
    xtype: 'main',
    //html: '<h1>Hello world</h1>',
    fullscreen: true,
    cardSwitchAnimation: 'slide',
    constructor: function () {
        this.callParent();
    },
    config: {
        tabBar: {
            id:'tabBar',
            docked: 'bottom',
            layout: {
                pack: 'center'
            }
        },
        items: [
            {
                xtype: 'panel',
                title: 'Panel 1',
                fullscreen: false,
                html: '<div id="hello">Hello World</div>',
                iconCls: 'bolt',
                items: [
                    {
                        dock: 'top',
                        xtype: 'toolbar',
                        title: 'About TouchStart'
                    },
                    {
                        dock: 'top',
                        xtype: 'toolbar',
                        ui: 'subnav',
                        items: [
                            {
                                text: 'Back',
                                ui: 'back'
                            },
                            {
                                text: 'Round',
                                ui: 'round'
                            },
                            {
                                text: 'Small',
                                ui: 'small'
                            },
                            {
                                text: 'Normal',
                                ui: 'normal'
                            },
                            {
                                text: 'Action',
                                ui: 'action'
                            },
                            {
                                text: 'Forward',
                                ui: 'forward'
                            }
                        ]
                    }
                ]
            },
            {
                xtype: 'list',
                grouped:true,
                indexBar:true,
                title: 'List',
                fullscreen: false,
                iconCls: 'bookmarks',
                itemTpl: '{id} - {fullname}',
                store: Ext.create('MyFirstApp.store.ItemsStore')

            },{ //here was my previos code with container and list now it in controlle

             }
          ]

    }

模型

Ext.define('MyFirstApp.model.OffiseModel', {
    extend:'Ext.data.Model',
    config:{
        fields:[{name:'text',type:'string'}]
    }
});     
**Store**


Ext.define('MyFirstApp.store.OffiseStore', {
    extend:'Ext.data.TreeStore',
    requires: 'MyFirstApp.model.OffiseModel',
    constructor:function(){
        console.log(this.items);
    },
config: {
    defaultRootProperty: 'items',
    model:'MyFirstApp.model.OfficeModel',
    root:

            {
                text: 'offices',
                items: [
                    {
                        text: 'Minsk Office',
                        items: [
                            {
                                text: 'Marketing',
                                items: [
                                    {text: 'David Smith',
                                        leaf: true
                                    },
                                    {
                                        text: 'David Blein',
                                        leaf: true
                                    }
                                ]
                            },
                            {
                                text: 'Sales',
                                items: [
                                    {
                                        text: 'Bryan Adams',
                                        leaf: true
                                    },
                                    {text: 'Angela Device',
                                        leaf: true}
                                ]
                            }
                        ]
                    },
                    {
                        text: 'Molodechno Office',
                        items: [
                            {
                                text: 'Marketing',
                                items: [
                                    {text: 'David MoloSmith',
                                        leaf: true
                                    },
                                    {
                                        text: 'David MoloBlein',
                                        leaf: true
                                    }
                                ]
                            },
                            {
                                text: 'Sales',
                                items: [
                                    {
                                        text: 'Bryan MoloAdams',
                                        leaf: true
                                    },
                                    {text: 'Angela MoloDevice',
                                        leaf: true}
                                ]
                            }
                        ]
                    }
                ]


              }//first object in data
    }
});

控制器

   Ext.define('MyFirstApp.controller.ProductsCtrl', {
        extend: 'Ext.app.Controller',
        requires:['MyFirstApp.view.ProductsDetailsView','MyFirstApp.view.CaruselView','MyFirstApp.view.MsgBoxView','MyFirstApp.view.MapView','Ext.Button','MyFirstApp.model.OffiseModel'],
        config: {
        },

        init: function(){

            this._View = Ext.create('MyFirstApp.view.MainView');
            var myContainer = {
                xtype:'container',
                fullscreen:true,
                title: 'Some other settings',
                iconCls: 'user'
            }
             var nestedStore = Ext.create('MyFirstApp.store.OffiseStore');
            console.log(nestedStore);
            var nestedList = {
                id:'myNestedList',
                xtype: 'nestedlist',
                fullscreen:true,
                store: nestedStore
            }      
            var tabBar = Ext.getCmp('tabBar');
            tabBar.add(nestedList);
            var nestedList = Ext.getCmp('myNestedList');
            nestedList.show();

            Ext.Viewport.add(this._View);        
        }

    });

0 个答案:

没有答案