setActiveItem函数正在触发但没有任何反应,我没有收到任何错误消息..,有人能告诉我为什么这不起作用吗?
Ext.regModel('team', {
fields: [
{name: 'name', type: 'string'},
]
});
Dashboard = new Ext.Application({
name:'Dashboard',
launch: function(){
//Info list
var detailPanel = new Ext.Panel({
id:'detailPanel',
dock:"top",
items: [{
fullscreen:true,
xtype: 'list',
store: new Ext.data.Store({
model: 'team',
getGroupString : function(record) {
return record.get('name')[0];
},
proxy: new Ext.data.AjaxProxy({
url: 'a.php/pool/listPools'
,method:'post',
reader: {
type: 'json',
root: 'data',
totalCount: 'count'
}
})
,autoLoad:true
}),
sorters: [{
property: 'name',
direction: 'asc'
}],
itemTpl:'<font size="4" face="Helvetica, Arial" color="black">{name}</font>',
grouped: true,
onItemDisclosure : true,
listeners : {
itemtap : function(record,index,item,e){
if (e.getTarget('.x-list-disclosure')) {
var recPool = this.store.data.items[index];
//Ext.Msg.alert([index]);
var redirect = 'showpool.php';
window.location = redirect;
}
// else { Ext.Msg.alert("Item clicked!");}
}
}
}]
})
var outer = new Ext.Panel({
fullscreen:true,
layout:'card',
items:[
detailPanel
]
});
//------------------------------------Toolbar top
var TopPanel = new Ext.Panel({
id:'testview',
fullscreen:true,
style: "background-color: #GGG;",
dockedItems: [
{
dock : 'top',
xtype: 'toolbar',
title: 'Pools',
ui:'light',
items: [
{
text: 'Logout',
ui:'back',
handler: function(){
outer.setActiveItem('detailPanel', { type: 'slide', cover: false, direction: 'left'});
}
}, {xtype: 'spacer'},
{
text: 'Refresh',
ui:'action',
handler: function(){
detailPanel.doLayout();
}
}
]
},
outer]
});
}
});
答案 0 :(得分:2)
你在这里用它作为字符串:
outer.setActiveItem('detailPanel',
{type: 'slide', cover: false, direction: 'left'});
改为使用变量:
outer.setActiveItem(detailPanel,
{type: 'slide', cover: false, direction: 'left'});
这应该有用。
答案 1 :(得分:1)
实际上,如果面板中添加了两个或更多项目,则使用卡片布局在视图之间切换。在您的情况下,外部面板包含一个视图。因此它将始终显示该面板。尝试将另一个面板添加到外部面板中,然后调用setActiveItem()。