我正在尝试将工具栏添加到我已创建的布局中。我有工具栏和布局的代码,但我不知道如何整合太多
对于我的工具栏
<script>
Ext.onReady(function () {
new Ext.Toolbar({renderTo: Ext.getBody(),
items: [{
xtype: 'button',
text: 'Menu Button',
menu: [{
text: 'Better'
}, {
text: 'Good'
}, {
text: 'Best'
}]
},'->', {
xtype: 'splitbutton',
text: 'Split Button',
menu: [{
text: 'Item One'
}, {
text: 'Item Two'
}, {
text: 'Item Three'
}]
},'', {
xtype: 'cycle',
showText: true,
minWidth: 100,
prependText: 'Quality: ',
items: [{
text: 'High',
checked: true
}, {
text: 'Medium'
}, {
text: 'Low'
}]
},]
});
});
</script>
对于我的布局,我有
<script>
var viewport = new Ext.Viewport({
layout: "border",
defaults: {
bodyStyle: 'padding:10px;',
},
items: [{
region: "north",
html: 'North',
margins: '5 5 5 5'
}, {
region: 'west',
collapsible: true,
title: 'Some Info',
width: 200,
html: 'West',
margins: '0 0 0 5'
}, {
region: 'center',
title: 'Our Info',
html: 'Center',
margins: '0 0 0 0'
}, {
region: 'east',
collapsible: true,
width: 200,
title: 'Their Info',
html: 'East',
margins: '0 5 0 0'
}, {
region: 'south',
title: 'Their Info',
html: 'South',
width: 200,
margins: '5 5 5 5'
}]
});
</script>
如何使用此页面上的工具栏? 感谢
@Justin,这是我的完整代码
var viewport = new Ext.Viewport({
layout: "border",
tbar: new Ext.Toolbar({
//Toolbar config options
items: [{
xtype: 'button',
height: 27,
text: 'Menu Button',
menu: [{
text: 'Better'
}, {
text: 'Good'
}, {
text: 'Best'
}]
}, '->',
{
xtype: 'splitbutton',
text: 'Split Button',
menu: [{
text: 'Item One'
}, {
text: 'Item Two'
}, {
text: 'Item Three'
}]
}, '',
{
xtype: 'cycle',
showText: true,
minWidth: 100,
prependText: 'Quality: ',
items: [{
text: 'High',
checked: true
}, {
text: 'Medium'
}, {
text: 'Low'
}]
}, ]
}),
defaults: {
bodyStyle: 'padding:10px;',
},
//layouf config
tems: [{
region: "north",
html: 'North',
margins: '5 5 5 5'
}, {
region: 'west',
collapsible: true,
title: 'Some Info',
width: 200,
html: 'West',
margins: '0 0 0 5'
}, {
region: 'center',
title: 'Our Info',
html: 'Center',
margins: '0 0 0 0'
}, {
region: 'east',
collapsible: true,
width: 200,
title: 'Their Info',
html: 'East',
margins: '0 5 0 0'
}, {
region: 'south',
title: 'Their Info',
html: 'South',
width: 200,
margins: '5 5 5 5'
}]
});
答案 0 :(得分:1)
您应该可以将工具栏作为配置选项添加到主面板的bbar或tbar。
var viewport = new Ext.Viewport({
layout: "fit",
items: [
//We add one "main" panel that fills up entire Viewport
{
layout: "border",
defaults: {
bodyStyle: 'padding:10px;',
},
tbar: new Ext.Toolbar({
//your Toolbar config options
}),
items: [
//your panels here
]
}
]
...
在这种情况下,您可能希望摆脱工具栏中的“renderTo”配置。