- 注册时间
- 2014-1-15
- 最后登录
- 2014-8-19
- 阅读权限
- 10
- 积分
- 178
- 精华
- 0
- 帖子
- 55
|
本帖最后由 zhangying 于 2014-4-16 10:34 编辑
felt 发表于 2014-4-16 10:31
没发现你说的问题,把代码贴一下
<div class="mini-fit">
<ul id="tree1" class="mini-tree" url="${ctx }/template/getData.do" style="width:200px;padding:5px;"
showTreeIcon="true" textField="busDictionaryValue" idField="id" parentField="busDdictionaryParentId" resultAsTree="false"
contextMenu="#treeMenu" expandOnLoad="true"
>
</ul>
<ul id="treeMenu" class="mini-contextmenu" onbeforeopen="onBeforeOpen">
<li class="separator"></li>
<li>
<span name="add" 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>
</div>
<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 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;
}
////////////////////////////////
debugger;
var addItem = mini.getbyName("add", menu);
var editItem = mini.getbyName("edit", menu);
var removeItem = mini.getbyName("remove", menu);
editItem.show();
removeItem.enable();
if(tree.isLeaf ( node )){
addItem.hide();
}
if (node.id == "forms") {
editItem.hide();
}
if (node.id == "lists") {
removeItem.disable();
}
} |
|