我有几个面板,布局是vbox和hbox dbclick面板标题时,如何实现最大和最小功能 这是代码:
Ext.create('Ext.panel.Panel', {
style: 'padding:0 10px 0 10px',
layout: {
align: 'stretch',
type: 'vbox'
},
renderTo: Ext.getBody(),
items: [{
xtype: 'panel',
border: 0,
layout: {
align: 'stretch',
type: 'vbox'
},
items: [{
xtype: 'panel',
height: 100,
title: 'title1',
html: 'panel1'
}, {
xtype: 'panel',
height: 100,
title: 'title2',
html: 'panel2'
}]
}, {
xtype: 'panel',
border: 0,
layout: {
align: 'stretch',
type: 'hbox'
},
items: [{
xtype: 'panel',
title: 'title3',
height: 100,
flex: 1,
html: 'panel3'
}, {
xtype: 'panel',
title: 'title3',
flex: 1,
html: 'panel4'
}]
}]
});
我有两个问题:
感谢。
答案 0 :(得分:1)
您应该在外部面板上定义dblclick
事件,然后使用toggleCollapse
功能,如下所示。
<强> REMARK:强>
不要使用不起作用的collapse
和expand
功能。 Juts使用toggleCollapse
Ext.create('Ext.panel.Panel', {
style: 'padding:0 10px 0 10px',
layout: {
align: 'stretch',
type: 'vbox'
},
renderTo: Ext.getBody(),
items: [{
xtype: 'panel',
border: 0,
layout: {
align: 'stretch',
type: 'vbox'
},
items: [{
xtype: 'panel',
height: 100,
title: 'title1',
html: 'panel1',
listeners: {
dblclick: {
fn: function() {
var pnl = Ext.getCmp('panel-out');
pnl.toggleCollapse();
},
element: 'el'
}
}
}, {
xtype: 'panel',
height: 100,
title: 'title2',
html: 'panel2'
}]
}, {
xtype: 'panel',
border: 0,
id: 'panel-out',
layout: {
align: 'stretch',
type: 'hbox'
},
items: [{
xtype: 'panel',
title: 'title3',
height: 100,
flex: 1,
html: 'panel3'
}, {
xtype: 'panel',
title: 'title3',
flex: 1,
html: 'panel4'
}]
}]
});
<强>更新强> 然后,尝试这个(我只是隐藏并显示面板)
Ext.create('Ext.panel.Panel', {
style: 'padding:0 10px 0 10px',
layout: {
align: 'stretch',
type: 'vbox'
},
renderTo: Ext.getBody(),
items: [{
xtype: 'panel',
border: 0,
layout: {
align: 'stretch',
type: 'vbox'
},
items: [{
xtype: 'panel',
height: 100,
title: 'title1',
html: 'panel1',
listeners: {
dblclick: {
fn: function() {
var pnl = Ext.getCmp('panel-out');
pnl.toggleCollapse();
},
element: 'el'
}
}
}, {
xtype: 'panel',
height: 100,
title: 'title2',
html: 'panel2'
}]
}, {
xtype: 'panel',
border: 0,
id: 'panel-out',
layout: {
align: 'stretch',
type: 'hbox'
},
items: [{
xtype: 'panel',
title: 'title3',
height: 100,
flex: 1,
html: 'panel3',
listeners: {
dblclick: {
fn: function() {
var pnl_three = Ext.getCmp('panel4');
if (pnl_three.hidden == false) {
pnl_three.hide();
} else {
pnl_three.show();
}
},
element: 'el'
}
}
}, {
xtype: 'panel',
title: 'title4',
id: 'panel4',
flex: 1,
html: 'panel4'
}]
}]
});