Extjs在panel的标题栏上加按钮的方法

Ext.define('MyPanel',{
    extend:'Ext.panel.Panel',
    xtype:'mypanel',
    title:'title',
    height:200,
    initComponent:function(){
        var me=this;
        me.okBtn = new Ext.button.Button({
            //按钮位置可通过此样式进行修改,如果按钮靠右显示可修改为把left改成right
            //采用此解决方案可以避免标题栏被撑高。
            style:'position: absolute;top: 5px;left: 60px;',
            text: 'ok',scope: me,
            handler:function(){
                alert('ok click');
            }
        });
        this.callParent();
    },
    onRender:function(){
        this.callParent(arguments);
        this.okBtn.render(Ext.get(this.getHeader().id));
    },
    onDestroy: function() {
        this.okBtn.destroy();
        this.callParent();
    }
});

猜你喜欢

转载自blog.csdn.net/wuzuyu365/article/details/84024995