zoukankan      html  css  js  c++  java
  • nui UI 具有右键属性的菜单树

    参考示例:树右键菜单
         

              
    一:创建ContextMenu    
    <ul id="treeMenu" class="nui-contextmenu"  onbeforeopen="onBeforeOpen">       
        <li iconCls="icon-move" onclick="onMoveNode">移动节点</li>
        <li class="separator"></li>
        <li>
            <span iconCls="icon-add">新增节点</span>
            <ul>
                <li onclick="onAddBefore">插入节点前</li>               
                <li onclick="onAddAfter">插入节点后</li>   
                <li onclick="onAddNode">插入子节点</li>                
            </ul>
        </li>
        <li name="edit" iconCls="icon-edit" onclick="onEditNode">编辑节点</li>
        <li name="remove" iconCls="icon-remove" onclick="onRemoveNode">删除节点</li>       
    </ul>
              
    二:设置contextmenu  
    <ul id="tree1" class="nui-tree" url="../data/tree.txt" style="200px;padding:5px;"
        showTreeIcon="true" textField="text" idField="id"
        contextMenu="#treeMenu">       
    </ul>
             
    三:监听beforeopen事件  
    function onBeforeOpen(e) {
        var menu = e.sender;
        var tree = nui.get("tree1");
        var node = tree.getSelectedNode();
        if (!node) {
            e.cancel = true;
        }
        if (node && node.text == "Base") {
            e.cancel = true;
            //阻止浏览器默认右键菜单
            e.htmlEvent.preventDefault();
            return;
        }
        ////////////////////////////////
        var editItem = nui.getbyName("edit", menu);
        var removeItem = nui.getbyName("remove", menu);
        editItem.show();
        removeItem.enable();
        if (node.id == "forms") {
            editItem.hide();
        }
        if (node.id == "lists") {
            removeItem.disable();
        }
    }
  • 相关阅读:
    centos7添加firewalld规则
    centos7安装redis5
    Oracle 监听
    创建Oracle表空间及用户
    nginx+keepalive
    oracle 修改端口
    Oracle新建数据库
    Redhat7.5安装JBOSS4.2.0
    kubernetes的一些基本命令
    安装python3.6后使用pip报错
  • 原文地址:https://www.cnblogs.com/godlovelian/p/5568962.html
Copyright © 2011-2022 走看看