甄伟 2011-08-25 10:22
浏览 239
已采纳

extjs2 menu显示不正常

以下是源码,点击menu here的时候也是仅仅出现一个小条
<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <title>extjs测试</title>

    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="cache-control" content="no-cache"/>
    <meta http-equiv="expires" content="0" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <link rel="stylesheet" type="text/css" href="css/ext-all.css" />
    <link rel="stylesheet" type="text/css" href="css/myStyle.css" />
    <link rel="stylesheet" type="text/css" href="css/icons.css" />
    <link rel="stylesheet" type="text/css" href="css/examples.css" />
    <link rel="stylesheet" type="text/css" href="css/column-tree.css" />
    <link rel="stylesheet" type="text/css" href="css/Spinner.css" />
    <link rel="stylesheet" type="text/css" href="css/fileuploadfield.css" />

    <script type="text/javascript" src="js/ext-base.js"></script>
    <script type="text/javascript" src="js/ext-all.js"></script>
    <script type="text/javascript" src="js/ext-lang-zh_CN.js"></script>



    <script type="text/javascript">

        Ext.onReady(function(){
             Ext.BLANK_IMAGE_URL = "../ext/resources/images/default/s.gif";   

var loader = new Ext.tree.TreeLoader({dataUrl: 'abc.txt'});
loader.processResponse = function(response, node, callback){
var json = response.responseText;
try {
var json = eval("("+json+")");

                node.beginUpdate();
                var o = json["root"];

                for(var i = 0, len = o.length; i < len; i++){
                    var n = this.createNode(o[i]);
                    if(n){
                        node.appendChild(n);
                    }
                }
                node.endUpdate();
                if(typeof callback == "function"){
                    callback(this, node);
                }
            }catch(e){
                this.handleFailure(response);
            }
        };

        var testMenu = new Ext.menu.Menu({//菜单容器

            minWidth:300,
            maxHeight:500,
            enableScrolling : true,
            item:[{
            id:'1', 
            icon:"icon-info.gif",
            text:'有本事点我',
            handler:function(){
                Ext.MessageBox.alert("","啊!我被击中了!");
            }},"-",{
            text:'有本事点我',
             icon:"icon-info.gif",
            handler:function(){
                Ext.MessageBox.alert("","啊!我被击中了!");
            }}]
        });
        var tree = new Ext.tree.TreePanel({
            el: 'tree',
            loader: loader
        });

        var root = new Ext.tree.AsyncTreeNode({text:'我是根'});

        tree.on("contextmenu",function(node,e){//contextmenu是右键菜单事件
            e.preventDefault();//用来防止浏览器弹出它默认的功能菜单
             e.stopEvent();   
            node.select();//当前节点处于选中状态
            testMenu.showAt(e.getXY());

        });
        tree.setRootNode(root);
        tree.render();

        root.expand();
        var el = Ext.get("test_menu");

          el.on("click",function(e){   
   //menu.showAt(e.getXY());//作用于该位置   
    testMenu.show(this);//作用于元素上   
    //e.getXY();//得到事件触发的坐标   
})  ;
        });

    </script>
</head>

<body>
    <div id='tree' style="height:60"></div>
    <div id="test_menu" style="height:60">menu here</div>
</body>

  • 写回答

2条回答 默认 最新

  • weixin_42468936 2011-08-25 11:14
    关注

    [code="java"]
    var testMenu = new Ext.menu.Menu({//菜单容器

    minWidth:300,
    maxHeight:500,
    enableScrolling : true,
    [color=red]item:[{ [/color] [color=darkred]//-->items啊 单词少了s 所以显示不出来[/color]id:'1',
    icon:"icon-info.gif",
    text:'有本事点我',
    handler:function(){
    Ext.MessageBox.alert("","啊!我被击中了!");
    }},"-",{
    text:'有本事点我',
    icon:"icon-info.gif",
    handler:function(){
    Ext.MessageBox.alert("","啊!我被击中了!");
    }}]
    });

    [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 swiftui @query 报错
  • ¥50 怎么解决刷卡或扫码后,点击软件输入框,win10屏幕键盘不会自动弹出的问题
  • ¥15 如何使用arcgispro的训练深度模型,发现water和nowater精度为0?(相关搜索:深度学习)
  • ¥20 matlab作业不太懂呀有问题能给个代码吗
  • ¥15 自制电路图为何无法驱动ESP01S?
  • ¥15 前端加access数据库
  • ¥15 ARCGIS 多值提取到点 ERROR 999999
  • ¥15 mysql异常断电, [MY-011971] [InnoDB]
  • ¥15 uni.onBluetoothDeviceFound熄屏不运行
  • ¥15 求PHDA糖尿病并发症数据集,有偿