0
我想從ToolBarView中獲取視口 - >中心區域的引用,當單擊工具欄中的註銷按鈕時,視口card0中的中心區域應設置爲activeItem。請有人幫助我。從視圖訪問視口中心區域並更改活動項目
//查看
Ext.define('MyApp.view.ToolBarView', {
extend: 'Ext.toolbar.Toolbar',
xtype: 'bottom-toolbar',
alias: 'widget.toolBar',
height: 40,
items: [
{
xtype: 'tbfill'
},
{
text: 'Home'
},
{
xtype: 'tbseparator'
},
{
xtype: 'button',
text: 'Settings',
scale: 'medium',
menu: [{
text:'My Profile'
},{
text:'Change Password'
},{
text:'View Options'
}]
},
{
xtype: 'tbseparator'
},
{
text: 'Logout',
handler: function() {
Ext.Msg.alert('Are you sure you want to logout??');
tex = button.up('toolbar'),//here i need to change viewport activeItem
tex.close()//close this toolbar view and logout and show loginView(card 0)
}
}
]
});
//My Viewport is
Ext.define('MyApp.view.Viewport', {
extend: 'Ext.container.Viewport',
layout: 'border',
requires: [
'MyApp.view.LoginView',
'MyApp.view.GridView',
'MyApp.view.RegisterForm',
'MyApp.view.TabView',
'MyApp.view.ToolBarView'
],
items: [
{
region: 'north',
border: false,
items:[
{ xtype: 'image',
src: 'images/logo.jpg',
width:200,
height:63
}
]
},
{
region: 'south',
html: 'Hello',
xtype: 'toolbar',
height: 25
},
{
region: 'center',
layout: 'card',
activeItem: 0,
items:
[{
id: 'card0',
xtype: 'container',
items:[ {xtype: 'loginView'}],
region: 'center',
layout: {
type: 'vbox',
align: 'center',
pack: 'center'
}
},
{
id: 'card1',
xtype: 'container',
items:[ {xtype: 'registerForm'}],
layout: {
type: 'vbox',
align: 'center',
pack: 'center'
}
},
{
items:[
{xtype: 'toolBar'},// this is the toolbar from which i need to access viewport and change the activeItem
{xtype: 'gridView'},
{xtype: 'tabView'}
]
}]
}]
});