<ul id="treeMenu" class="mini-contextmenu" >
<li iconCls="icon-move">移动节点</li>
<li class="separator"></li>
<li>
<span iconCls="icon-add">新增节点</span>
<ul>
<li>插入节点前</li>
<li>插入节点后</li>
<li>插入子节点</li>
</ul>
</li>
<li name="edit" iconCls="icon-edit">编辑节点</li>
<li name="remove" iconCls="icon-remove">删除节点</li>
</ul>
<div style="padding-top:5px;color:red;">Note:
<ol>
<li>禁止右键菜单:Base节点不显示右键菜单</li>
<li>隐藏菜单项:Forms节点,隐藏"删除节点"菜单项</li>
<li>禁用菜单项:Lists节点,禁用"编辑节点"菜单项</li>
</ol>
</div>
<iframe width="100%" height="100%" frameborder="1" id="fileFrame" name="fileFrame" marginwidth="0" marginheight="0"/>
<script type="text/javascript">
function onAddBefore(e) {
var tree = mini.get("tree1");
var node = tree.getSelectedNode();
var newNode = {};
tree.addNode(newNode, "before", node);
}
function onAddAfter(e) {
var tree = mini.get("tree1");
var node = tree.getSelectedNode();
var newNode = {};
tree.addNode(newNode, "after", node);
}
function onAddNode(e) {
var tree = mini.get("tree1");
var node = tree.getSelectedNode();
var newNode = {};
tree.addNode(newNode, "add", node);
}
function onEditNode(e) {
var tree = mini.get("tree1");
var node = tree.getSelectedNode();
tree.beginEdit(node);
}
function onRemoveNode(e) {
var tree = mini.get("tree1");
var node = tree.getSelectedNode();
if (node) {
if (confirm("确定删除选中节点?")) {
tree.removeNode(node);
}
}
}
function onMoveNode(e) {
var tree = mini.get("tree1");
var node = tree.getSelectedNode();
alert("moveNode");
}
function onBeforeOpen(e) {
var menu = e.sender;
var tree = mini.get("tree1");
var node = tree.getSelectedNode();
if (!node) {
e.cancel = true;
return;
}
if (node && node.text == "Base") {
e.cancel = true;
//阻止浏览器默认右键菜单
e.htmlEvent.preventDefault();
return;
}
////////////////////////////////
var editItem = mini.getbyName("edit", menu);
var removeItem = mini.getbyName("remove", menu);
editItem.show();
removeItem.enable();
if (node.id == "forms") {
editItem.hide();
}
if (node.id == "lists") {
removeItem.disable();
}
}
</script>
<div class="description">
<h3>Description</h3>
<p>
</p>
</div>
</body>
</html> 作者: niko 时间: 2012-12-23 10:05:32