显示选项卡而不显式单击选项卡图标

时间:2013-02-09 09:04:24

标签: extjs sencha-touch

我目前正在使用Sencha Touch 1开发应用程序。 我的TabPanel中有2个项目。搜索和警报。

单击“搜索”选项卡会显示4的列表。 当用户点击列表中的第4项时,他应该自动定向到警报标签,而无需手动点击标签。

我是否可以使用任何功能。

我是Sencha touch的初学者。欢迎提出建议。

这是我的app.js

ToolbarDemo=new Ext.Application({
name:'ToolbarDemo',






launch:function(){





ToolbarDemo.views.Viewport=new Ext.TabPanel({
    fullscreen:true,

    defaults:
    {
        html:'',
        styleHtmlContent:true,

    } ,

    tabBar:
    {
        dock:'bottom',
        layout:{
            pack:'center'
        }

    },

    items:[
                    /*
                    {
                    xtype:'homecard'
                    },
                    */
                    {
                    xtype:'searchcard'
                    },
                    /*
                    {
                    xtype:'actioncard'
                    },
                    */                      {
                    xtype:'settingscard'

                    },

                    {
                     xtype:'morecard'

                    },







          ] ,

       });







}
});

searchcard有以下代码(searchcard.js)

          Ext.regModel('Contact',{

                      fields:['firstName','lastName']
                  });

                   //create a store
                  var liststore = new Ext.data.Store({

                   model:'Contact',
                   getGroupString:function(record){
                               return record.get('firstName')[0];

                               },

                  data:[
                                       {firstName:'Network Summary'},
                                       {firstName: 'Alarms and Alerts'},

                       ]

                  });

                detailpanel=new Ext.Panel({
                                                layout:'fit',
                                                id:'detailpanel',
                                                html:'HELLO ',
                                            });


                listpanel =new Ext.List({

                         id:'indexlist',
                         store:liststore,    //take data from store created above
                         itemTpl:'{firstName}',

                         indexBar:true ,    //property of list
                         onItemDisclosure:function(record)

                                                    {



                                                             mainpanel.setActiveItem('detailpanel');

                                                    }
                        });
                 mainpanel=new Ext.Panel({

                                                                id:'mainpanel',
                                                                layout:'card',

                                                                items:[
                                                                listpanel,detailpanel
                                                                ],

                                                            });


ToolbarDemo.views.Searchcard= Ext.extend(Ext.Panel,{
    title:'Search',
    iconCls:'search',
    badgeText:'1',
    layout:'fit',
    //items:[listpanel],

    initComponent: function() {
            Ext.apply(this, {
                items:[mainpanel],
            });
            ToolbarDemo.views.Searchcard.superclass.initComponent.apply(this, arguments);
        }

})  ;

Ext.reg('searchcard',ToolbarDemo.views.Searchcard);

我的闹钟标签包含以下代码(morecard.js)

                              Ext.regModel('Contact',{

                                      fields:['firstName','lastName']
                                  });
                    var liststore = new Ext.data.Store({

                                      model:'Contact',
                                      getGroupString:function(record){
                                                  return record.get('firstName')[0];

                                                  },

                                     data:[
                                                          {firstName:'Critical Alarms'},
                                                          {firstName: 'Major alarms'},
                                                          {firstName: 'Minor alarms'},
                                                          {firstName: 'Alerts'},
                                          ]

                                     });

                         detailpanel=new Ext.Panel({

                                                                        id:'detailpanel',
                                                                        tpl:'HELLO ',
                                                                    });


                        listpanel_my =new Ext.List({

                                                id:'indexlist',
                                                store:liststore,    //take data from store created above
                                                itemTpl:'{firstName}',

                                                indexBar:true ,    //property of list
                                                onItemDisclosure:function(record)

                                                                           {



                                                                                  //   ToolbarDemo.views.Viewport.setActiveItem('detailpanel');

                                                                           }
                                               });


            ToolbarDemo.views.Morecard = Ext.extend(Ext.Panel, {
                title: "Alarms",
                iconCls: "more",
                cardSwitchAnimation: 'slide',
                initComponent: function() {
                    Ext.apply(this, {
                      items:[listpanel_my] ,
                    });
                    ToolbarDemo.views.Morecard.superclass.initComponent.apply(this, arguments);
                }
            });

            Ext.reg('morecard', ToolbarDemo.views.Morecard);

当我在搜索标签(searchard.js)中单击名为“警报和警报”的列表项后,我会自动希望我自动希望我的“警报”选项卡处于活动状态并显示其项目(主要警报,次要警报等)

1 个答案:

答案 0 :(得分:1)

您的TabPanel有一个名为setActiveItem(item)的方法,其中item是一个数字。

另请参阅Sencha Touch Docs regarding this methodContainerTabPanel的超类。