<SCRIPT type="text/javascript">
var setting = {
view : {
addHoverDom : addHoverDom,
removeHoverDom : removeHoverDom,
selectedMulti : false
},
edit : {
enable : true,
editNameSelectAll : true,
showRemoveBtn : showRemoveBtn,
showRenameBtn : showRenameBtn
},
data : {
simpleData : {
enable : true
}
},
callback : {
beforeDrag : beforeDrag,
beforeEditName : beforeEditName,
beforeRemove : beforeRemove,
beforeRename : beforeRename,
onRemove : onRemove,
onRename : onRename,
beforeClick : beforeClick,
onAsyncSuccess : zTreeOnAsyncSuccess
}
};

var zNodes = [];
var log, className = "dark";

function zTreeOnAsyncSuccess(event, treeId, treeNode, msg) {
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
zTree.refresh();
};

function beforeClick(treeId, treeNode) {
//alert(treeId + ' | ' + treeNode.pId + ' | ' + treeNode.tId);
//windows.open("${contextPath}/auth/functionform","窗口名称","height=100,width=100");
//windows.iframe_a.location.href = "${contextPath}/auth/functionform";
/* <a href="${contextPath}/auth/functionform?fid=${v.fid}" target="iframe_a">W3School.com.cn</a> */

alert(treeNode.id);

if (treeNode.level == 0) {
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
zTree.expandNode(treeNode);
return false;
}

//windows.rightFrame.location.href="${contextPath}/auth/functionform";
ajax_get("${contextPath}/auth/removeztree", "&id=" + treeNode.id, function(data) {
//var data=obj;
if (data.errorMessage) {
showmsg(0, data.errorMessage);
} else {
//showmsg(1, "处理成功!");
//$('#id').val=(data.xxx);
}
});

return true;
}

function beforeDrag(treeId, treeNodes) {
return false;
}
function beforeEditName(treeId, treeNode) {
className = (className === "dark" ? "" : "dark");
showLog("[ " + getTime() + " beforeEditName ]&nbsp;&nbsp;&nbsp;&nbsp; " + treeNode.name);
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
zTree.selectNode(treeNode);
//return confirm("进入节点 -- " + treeNode.name + " 的编辑状态吗?");
return true;
}
function beforeRemove(treeId, treeNode) {
className = (className === "dark" ? "" : "dark");
showLog("[ " + getTime() + " beforeRemove ]&nbsp;&nbsp;&nbsp;&nbsp; " + treeNode.name);
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
zTree.selectNode(treeNode);
return confirm("确认删除 节点 -- " + treeNode.name + " 吗?");
}
function onRemove(e, treeId, treeNode) {
ajax_get("${contextPath}/auth/removeztree", "&id=" + treeNode.id, function(data) {
if (data.errorMessage) {
showmsg(0, data.errorMessage);
} else {
showmsg(1, "处理成功!");

}
});
showLog("[ " + getTime() + " onRemove ]&nbsp;&nbsp;&nbsp;&nbsp; " + treeNode.name);
}
function beforeRename(treeId, treeNode, newName, isCancel) {
className = (className === "dark" ? "" : "dark");
showLog((isCancel ? "<span style='color:red'>" : "") + "[ " + getTime() + " beforeRename ]&nbsp;&nbsp;&nbsp;&nbsp; " + treeNode.name
+ (isCancel ? "</span>" : ""));
if (newName.length == 0) {
alert("节点名称不能为空.");
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
setTimeout(function() {
zTree.editName(treeNode);
}, 10);
return false;
}

ajax_get("${contextPath}/auth/renameztree", "&id=" + treeNode.id + "&sname=" + newName, function(data) {
if (data.errorMessage) {
showmsg(0, data.errorMessage);
} else {
showmsg(1, "处理成功!");
}
});
return true;
}
function onRename(e, treeId, treeNode, isCancel) {
showLog((isCancel ? "<span style='color:red'>" : "") + "[ " + getTime() + " onRename ]&nbsp;&nbsp;&nbsp;&nbsp; " + treeNode.name
+ (isCancel ? "</span>" : ""));
}
function showRemoveBtn(treeId, treeNode) {
/* return !treeNode.isFirstNode; */
return true;
}
function showRenameBtn(treeId, treeNode) {
/* return !treeNode.isLastNode; */
return true;
}
function showLog(str) {
if (!log)
log = $("#log");
log.append("<li class='"+className+"'>" + str + "</li>");
if (log.children("li").length > 8) {
log.get(0).removeChild(log.children("li")[0]);
}
}
function getTime() {
var now = new Date(), h = now.getHours(), m = now.getMinutes(), s = now.getSeconds(), ms = now.getMilliseconds();
return (h + ":" + m + ":" + s + " " + ms);
}

var newCount = 1;
function addHoverDom(treeId, treeNode) {
var sObj = $("#" + treeNode.tId + "_span");
if (treeNode.editNameFlag || $("#addBtn_" + treeNode.tId).length > 0)
return;
var addStr = "<span class='button add' id='addBtn_" + treeNode.tId + "' title='add node' onfocus='this.blur();'></span>";
sObj.after(addStr);
var btn = $("#addBtn_" + treeNode.tId);
if (btn) {
btn.bind("click", function() {
var zTree = $.fn.zTree.getZTreeObj("treeDemo");

var spId = treeNode.id;
var sname = "new node" + (newCount++);
var sid = RndNum(8);
addztree(sid, spId, sname);
zTree.addNodes(treeNode, {
id : sid,
pId : spId,
name : sname
});
return false;
});
}
};

function addztree(id, pId, name) {
ajax_get("${contextPath}/auth/addztree", "&id=" + id + "&pid=" + pId + "&sname=" + name, function(data) {
if (data.errorMessage) {
showmsg(0, data.errorMessage);
} else {
showmsg(1, "处理成功!");
}
});
}

function RndNum(n) {
var rnd = "";
for (var i = 0; i < n; i++)
rnd += Math.floor(Math.random() * 10);
return rnd;
}

/* function guid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
} */

function removeHoverDom(treeId, treeNode) {
$("#addBtn_" + treeNode.tId).unbind().remove();
};
function selectAll() {
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
zTree.setting.edit.editNameSelectAll = $("#selectAll").attr("checked");
}

$(document).ready(function() {

var s = $('#hinitnodes').val();
if (s != "") {
s = s.replace(/\'/g, "\"");
zNodes = JSON.parse(s);
}

$.fn.zTree.init($("#treeDemo"), setting, zNodes);
$("#selectAll").bind("click", selectAll);
});
</SCRIPT>

ztree edit_super的更多相关文章

  1. 可编辑ztree节点的增删改功能图标控制---已解决

    每文一语:休倚时来势,提防运去时 <!DOCTYPE html> <HTML> <HEAD> <TITLE> ZTREE DEMO - beforeEd ...

  2. javascript入门 之 zTree(十四 增删查改)(一)

    <!DOCTYPE html> <HTML> <HEAD> <TITLE> ZTREE DEMO - beforeEditName / beforeRe ...

  3. ztreeDeptSelect 基于jquery和ztree的部门选择插件

    插件介绍 首先我们来看插件的功能演示(效果): 插件准备好后.前台只需编写html: <input type="text" class="deptName" ...

  4. C#使用Jquery zTree实现树状结构显示_异步数据加载

    JQuery-Ztree下载地址:https://github.com/zTree/zTree_v3 JQuery-Ztree数结构演示页面:  http://www.treejs.cn/v3/dem ...

  5. 【笔记】ztree的使用

    引用的js和css: <!-- zTreeJS --><script type="text/javascript" src="jquery/jquery ...

  6. zTree和SweetAlert插件初探

    1.zTree插件简介 zTree是一个依靠 jQuery实现的多功能“树插件”.优异的性能.灵活的配置.多种功能的组合是zTree最大优点.专门适合项目开发,尤其是树状菜单.树状数据的Web显示.权 ...

  7. jQuery.zTree的跳坑记录

    最近项目用到树型结构的交互,一开始并不打算选择zTree,为了项目进度我妥协了,这一妥协后果就是我进坑了,在2天的挣扎中,我终于跳出坑了,活了下来,有一些感慨纪录下来. 有一个业务场景需要2个树型结构 ...

  8. ztree + ashx +DataTable +Oracle

    问题描述 好久没有使用ztree了,刚才在使用ztree做导航时遇到了几个小问题: 1.返回数据源是undefined . 2.数据出现后树结构没有出现(pIdKey单词拼写错误). 3.在使用Ora ...

  9. js树形控件—zTree使用总结

    0 zTree简介 树形控件的使用是应用开发过程中必不可少的.zTree 是一个依靠 jQuery 实现的多功能 “树插件”.优异的性能.灵活的配置.多种功能的组合是 zTree 最大优点. 0.0 ...

随机推荐

  1. MSChart BarChart

    不让合并0-5 chart1.ChartAreas[].AxisX.LabelStyle.Interval = ; 效果

  2. glyphicons-halflings-regular.ttf 404

    这个是用bootstrap框架时我遇到的问题,个人解决过程如下: ① 这个资源不是我手动引用的,是bootstrap.min.css文件间接调用的. ② 默认的路径是css文件路径是project/c ...

  3. R 给data.frame(dataframe)添加一列

    x<-data.frame(apple=c(1,4,2,3),pear=c(4,8,5,2)) x # apple pear # 1 1 4 # 2 4 8 # 3 2 5 # 4 3 2 x$ ...

  4. [SAP ABAP开发技术总结]Form(subroutine)、Function参数传值传址

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  5. ctrl+z暂停任务

    (1) CTRL+Z挂起进程并放入后台 (2) jobs 显示当前暂停的进程 (3) bg %N 使第N个任务在后台运行(%前有空格) (4) fg %N 使第N个任务在前台运行 默认bg,fg不带% ...

  6. iOS 框架收集

    检测硬件设备信息 https://github.com/Shmoopi/iOS-System-Services

  7. hdu 4123 Bob’s Race 树的直径+rmq+尺取

    Bob’s Race Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Probl ...

  8. HDU-4507 吉哥系列故事——恨7不成妻 数位DP

    题意:给定区间[L, R]求区间内与7无关数的平方和.一个数当满足三个规则之一则认为与7有关:1.整数中某一位是7:2.整数的每一位加起来的和是7的整数倍:3.这个整数是7的整数倍: 分析:初看起来确 ...

  9. Connection的使用

    package com.cz.test.util.collection; import java.util.ArrayList;import java.util.Collection;import j ...

  10. [js] 非常好的面试题,学习了。。

    原文链接:http://www.cnblogs.com/xxcanghai/p/5189353.html