2012-02-06 11 views
1

私はすでに作成したレイアウトにツールバーを追加しようとしています。私は、ツールバーとレイアウトの両方のためのコードを持っているが、私は、私が持っている私のツールバーextjsのレイアウトにツールバーを追加するにはどうすればよいですか?

<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' 
}] 
}); 

答えて

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」設定を取り除きたいと思うでしょう。

+0

ちょっとジャスティン、お返事ありがとうございます。私はまだちょっと残っている!私はextjsの初心者なので、どうしたらいいか分からない。あなたの回答を使って自分のコードを編集しますが、まだ進歩していません。私の完全なコードを見て、何かが欠けている場合は私をtekllしてください。ありがとう – Tony

+0

トニー - 私は見ることができるようにあなたの全体のコードをコピーします。最初に私が見るのは、あなたがrenderTo設定オプションを削除したときに、あなたは "{"のオープニングも削除したことです。 configオプションのオブジェクトを受け付ける新しいツールバーを作成しているので、新しいExt.Toolbar({//あなたの設定オプション})が必要です。 – Justin

+0

、ありがとうございます。今、このコードは私のレイアウトを示していますが、まだ私のツールバーを表示することができません。 – Tony

関連する問題