setActiveItem(0)的Tabview不显示sencha touch2中的页面内容

时间:2012-06-13 13:16:10

标签: sencha-touch extjs sencha-touch-2

我有四个separete视图,在单个tabview中添加这四个视图,如下所示。

标签查看代码:

Ext.define("SLS.BRND.WEB.view.MainTabbarView", {
    extend: 'Ext.tab.Panel',
    xtype: 'MainTabbarView',
    requires: ['Ext.data.proxy.JsonP', 'Ext.TitleBar', 'Ext.Video', 'SLS.BRND.WEB.view.GallerysView', 'SLS.BRND.WEB.view.FloorView'],
    config: {
        tabBarPosition: 'bottom',
        items: [
            {
                xclass: "SLS.BRND.WEB.view.GlobalNavigationView",
                docked: "top",
                scrollable: false
            },
            {
                xclass: 'SLS.BRND.WEB.view.ApartmentView'                    
            },
            {              
                xclass: 'SLS.BRND.WEB.view.SpecificationView'
            },
            {                
                xclass: 'SLS.BRND.WEB.view.FloorView'
            },
            {                
                xclass: 'SLS.BRND.WEB.view.GallerysView'
            }
          ]
    }
});

在控制器onbuttontap功能中,我在“MainTabbarView”页面上方调用,如下所示。我已经设置了setActiveItem(0);在四个中显示第一个tabitem(xclass:'SLS.BRND.WEB.view.ApartmentView')。当我设置像这个setActiveItem(0)时,它将显示第一个视图页面,但没有数据(空白屏幕)。如果我设置像这个setActiveItem(1),它将显示第二个视图页面与数据。然后我认为可能是第一页的问题,所以我在'MainTabbarView'中更改了页面视图的顺序。我再次设置setActiveItem(0)然后显示活动页面但没有数据。我一直在改变setActiveItem(0)到1,2,3它的工作正常以及数据显示。 但是对于setActiveItem(0)数​​据未显示。可以帮助我。如何解决这个问题。谢谢

控制器代码:

Ext.define("SLS.BRND.WEB.controller.ApartmentController", {
    extend: "Ext.app.Controller",
    requires: ['Ext.data.proxy.JsonP'],
    config: {
        refs: {
        projectsPage: "projectspage",            
            mainTabbarView: "MainTabbarView",         
        },
    control: {

            projectsPage: {               
               BtnApartments: "onAptButtonTap"               

            }
        }
  },
    onAptButtonTap: function () {
        var ApartmentTabbar = this.getMainTabbarView();
        ApartmentTabbar.setActiveItem(0);
        Ext.Viewport.animateActiveItem(ApartmentTabbar, this.slideLeftTransition);
    },
    activateNotesList: function () {
        Ext.Viewport.animateActiveItem(this.getHomepage(), this.slideRightTransition);
    },
    slideRightTransition: { type: 'slide', direction: 'right' },
    slideDownTransition: { type: 'flip', direction: 'down' },
    slideLeftTransition: { type: 'fade', direction: 'left' }

});

1 个答案:

答案 0 :(得分:0)

你的onAptButtonTap函数不在正确的位置,你把它放在配置中,因为你应该把它放在配置之后,如下所示:

...
config: {
    refs: {
        projectsPage: "projectspage",            
        mainTabbarView: "MainTabbarView",         
    },
    control: {
        projectsPage: {               
           BtnApartments: "onAptButtonTap"  
        }
    },
    ...
},
onAptButtonTap: function () {
    var ApartmentTabbar = this.getMainTabbarView();
    ApartmentTabbar.setActiveItem(0);
    Ext.Viewport.animateActiveItem(ApartmentTabbar, this.slideLeftTransition);
},
...
相关问题