动态加载;toolbar

第一种方式:直接传输事件绑定在里面   
var aa = "[{text : '模板充值类',scope:this,handler:function(){this.inter_interface.onEditInter(306);}}]"; 
        var a = Ext.decode(aa);
        console.log(a);
        var scrollMenu = new Ext.menu.Menu();
        scrollMenu.add(a);
        this.toolbar = [{
                id: 'addButton',
                text: '添加接口',
                iconCls: 'add',
                scope: this,
                menu : [
                {
                    text : '模板添加',
                    scope: this,
                    menu :scrollMenu
.......
第二种方式:事件事后添加
        var aa = "[{text : '模板充值类',scope:this}]";
        var a = Ext.decode(aa);
        console.log(a);
        var scrollMenu = new Ext.menu.Menu();
        scrollMenu.add(a);
        var _this = this;
        scrollMenu.on('click', function(){_this.onEditInter(306);});
        this.toolbar = [{
                id: 'addButton',
                text: '添加接口',
                iconCls: 'add',
                scope: this,
                menu : [
                {
                    text : '模板添加',
                    scope: this,
                    menu :scrollMenu
 
.......
第三种方式:页面中加载 同步传输
<script type="text/javascript" src="/public/js/ext/adapter/ext/ext-basex.js"></script>
 
 var rs ;
        Ext.Ajax.request({
            url : 'InterfaceMgr_1/menu_info',
            method: 'post',
            async : false,
            success: function( result, request ){
                 rs = Ext.decode(result.responseText);
            },
            failure: function( result, request){
                Ext.MessageBox.alert('Failed', '获取信息失败');
            }
        });
 
var scrollMenu = new Ext.menu.Menu();
        var _this = this;
        Ext.each(rs,function(result){
            var btn = new Ext.menu.Item({
                text : result.name
            });
            btn.on('click',function(){
                _this.onEditInter(result.id);
            });
            scrollMenu.add(btn);
        });
 
 
        this.toolbar = [{
                id: 'addButton',
                text: '添加接口',
                iconCls: 'add',
                scope: this,
                menu : [
                {
                    text : '模板添加',
                    scope: this,
                    menu :scrollMenu
 
 

附件列表

     

    posted @ 2012-06-12 11:01  holyes  阅读(304)  评论(0编辑  收藏  举报