firesnake2011 2010-08-18 21:50
浏览 174
已采纳

extjs 的desktop关联二级菜单执行事件问题

在extjs自己带的例子里是桌面图标对应的关联是一级菜单事件。
MyDesktop.GridWindow = Ext.extend(Ext.app.Module, {
id:'grid-win', //这里定义了ID,到desktop.html可以关联
init : function(){
this.launcher = {
text: 'Grid Window',
iconCls:'icon-grid',
handler : this.createWindow,
scope: this
}
},

createWindow : function(){
    var desktop = this.app.getDesktop();
    var win = desktop.getWindow('grid-win');
    if(!win){
        win = desktop.createWindow({
            id: 'grid-win',
            title:'Grid Window',
            width:740,
            height:480,
            iconCls: 'icon-grid',
            shim:false,
            animCollapse:false,
            constrainHeader:true,

            layout: 'fit',
            items:
                new Ext.grid.GridPanel({
                    省略。。。。。 })
    win.show();
}

});

对应的desktop.html中

[size=large][b]以上没有问题[/b][/size]

[b][size=x-large]问题如下:

但现在做了二级菜单:[/size][/b]

var windowIndex = 0;

MyDesktop.BogusModule = Ext.extend(Ext.app.Module, {

init : function(){
    this.launcher = {
        text: 'Window '+(++windowIndex), 
        iconCls:'bogus',
        handler : this.createWindow,
        scope: this,
        windowId:windowIndex
    }
},

createWindow : function(src){
    var desktop = this.app.getDesktop();
    var win = desktop.getWindow('bogus'+src.windowId);
    if(!win){
        win = desktop.createWindow({
            id: 'bogus'+src.windowId,
            title:src.text,
            width:640,
            height:480,
            html : '<p>Something useful would be in here.</p>',
            iconCls: 'bogus',
            shim:false,
            animCollapse:false,
            constrainHeader:true
        });
    }
    win.show();
}

});

MyDesktop.CollegeMenuModule = Ext.extend(MyDesktop.BogusModule, {

init : function(){
    this.launcher = { 
        iconCls: 'x-icon-waiting',
        scope: this,
        shortcutIconCls: 'demo-bogus-shortcut',
        text: ' 构建111',
        handler: function() {
            return false;
        }, 
     menu: {
            items:[{  
                 text: 'GOOGLE库'+(++windowIndex),
                iconCls:'bogus', 
                handler : this.createWindow,
                scope: this,
                windowId: windowIndex 

                },{  
                text: 'WEB库 '+(++windowIndex),
                iconCls:'bogus',
                handler : this.createWindow,
                scope: this,
                windowId: windowIndex
                },{  
                text: '测试库 '+(++windowIndex),
                iconCls:'bogus',
                handler : this.createWindow,
                scope: this,
                windowId: windowIndex
                } ]
        }
    }}
});

[size=large][b] [color=red]这样的话在 desktop.html中该怎么写啊?ID这个怎么写,请教。想关联到 'WEB库 '[/color] [/b][/size]



[/color]

WEB库 1234




测试库构建


初学,不太会用。不明白这里子menu的id怎么给,写什么??
请教好心人解答。
谢谢

  • 写回答

1条回答 默认 最新

  • lizhiyezi 2010-08-19 09:51
    关注

    menu 不能给的。dt id 对应 MyDesktop.BogusMenuModule 的id。
    在执行createWindow的函数可能会出现问题。

    你可以参考 Ext.Desktop shortcuts 事件代码 及 Ext.app.App.getModule() 函数,可对其修改达到你的要求

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记