Ext如何给Toolbar添加按钮

Ext.onReady(function() {
   
var tbar = new Ext.Toolbar({
        height:
50,
        items: [
new Ext.Button({ text: "button here",
            handler:
function(btn) {
                Ext.MessageBox.alert(
"it's a button here!");
            }
        })]
    });
   
var p = new Ext.Panel({
        tbar: tbar,
        renderTo: Ext.getBody()
    });
   
// 如果addButton写在这里就不行
    //写在这里是因为上面panel已经初始化了。
    //这样写:
    p.getTopToolbar().add([{
        text:
"save"
    },
    {
        text:
"close"
    }]);
    p.doLayout();
});
posted @ 2011-11-09 14:26  子萧  阅读(1257)  评论(0)    收藏  举报