本帖最后由 hua_wei 于 2009-09-25 09:27:03 编辑

解决方案 »

  1.   

    菜单是三级的,我就是想知道在js里面是如何动态的构建那个menu的
      

  2.   

    MyDesktop.BogusModule = Ext.extend(Ext.app.Module, {
                        init : function(){
                            this.launcher = {
                                text: 'Window '+(++windowIndex),
                                iconCls:'bogus',
                                handler : this.createWindow,
                                scope: this,
                                windowId:windowIndex
                            }
                        }, //end init                    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:1024,
                                    height:768,
                                    html : '<iframe frameborder="0" width="100%" height="100%" src="'+src.url+'"></iframe>',
                                    iconCls: 'icon-grid',
                                    //shim:false,
                                    height:(!!src.height)?(src.height):(768),
                                    width:(!!src.width)?(src.width):(1024),
                                    resizable:(src.disresize)?(false):(true),
                                    animCollapse:false,
                                    constrainHeader:true
                                });
                            }
                            win.show();
                        } //end createWindow
                    }); //end MyDesktop.BogusModule                var shipManage = Ext.extend(MyDesktop.BogusModule, {
                        init : function(){
                            this.launcher = {
                                text: '船舶管理',
                                iconCls: 'bogus',
                                handler: function() {
                                    return false;
                                },
                                menu: {
                                    items:[{//0
                                            text: "船舶公司信息",
                                            iconCls:'icon-grid',
                                            handler : this.createWindow,
                                            scope: this,
                                            url:"./shipManage/shipCorp.html",
                                            windowId: ++windowIndex
                                        },{//1
                                            text: "船舶信息",
                                            iconCls:'icon-grid',
                                            handler : this.createWindow,
                                            scope: this,
                                            url:"./shipManage/ship.html",
                                            windowId: ++windowIndex
                                        }]//end items
                                }//end menu
                            }//end launcher
                            if(purview.substr(1,1)=="0"){//控制船舶公司信息
                                this.launcher.menu.items.remove(this.launcher.menu.items[0]);
                            }
                            if(purview.substr(2,1)=="0"){//控制船舶信息
                                this.launcher.menu.items.remove(this.launcher.menu.items[1]);
                            }
                        }//end init
                    });类似这样的一个,我想从数据库取出来动态生成desktop的start
      

  3.   

    var jobj = [        
            {
    text : "<s:property value="CodeName"></s:property>",
    id : "<s:property value="ascode"></s:property>",
    pid: "",
    idx : "0"
    },
             <s:iterator value="wbsTrees">
            {
            text:"<s:property value="pmwbsWbsname"></s:property>",
            id:"<s:property value="pmwbsWbsid"></s:property>",
            hrefTarget:"this-main",
            seq:<s:property value="pmwbsSequence" />,
            pid:'<s:property value="pmwbsParentid" />',
            idx:"<s:property value="0"></s:property>"
            },
            </s:iterator>
            null
            ];
    jobj.pop();
    window.root = json2tree(jobj);

    // build the tree 
    var viewport =  new Ext.Viewport({
    layout : "border",
    items : [
    new Ext.tree.TreePanel({
    region : "west",
    id : "nav-tree",
    width : 230,
    split : true,
    // autoScroll : true,
    // collapsible: false,
    title : i18n_wbs,
    margins : '5 0 5 5',
    enableDD : true,
    root : root,
    onRender : function(){
    Ext.tree.TreePanel.prototype.onRender.apply(this, arguments);
    setTimeout(function(){
    Ext.tree.TreeNode.prototype.sort = function(){};
    }, 1000);
    },
    tbar : [btnRefresh,btnUpdate]
    }),
    new Ext.Panel({
    aotoHeight : true,
    region : 'center',
    //margins:'5 5 5 0',
    id : 'center-panel'
    })

    ]
    });
    function json2tree(jobj){
    var root;
    jobj.each(function(obj){
    var node = new Ext.tree.TreeNode(obj);
    JNode.ns[node.attributes.id] = node;
    });

    for (var t in JNode.ns){
    var node = JNode.ns[t];
    if (node.constructor != Ext.tree.TreeNode)
    continue;
    else if (node.attributes.pid === undefined || node.attributes.pid === "")
    root = node;
    else if(JNode.ns[node.attributes.pid] !== undefined){
    JNode.ns[node.attributes.pid].appendChild(node);
    }
    else 
    throw new Error("Wrong data in node, " + node);
    }

    return root;
    }
      

  4.   

    我不要树,我是说在desktop的时候动态获取