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() 函数,可对其修改达到你的要求

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

报告相同问题?

悬赏问题

  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R