菜单

JQuery写动态树示例代码,插件实现增删改查demo

2019年8月2日 - 前端排行

// 业务类型树
var settingOther = {
edit: {
enable: false
},
// 异步加载树
async: {
enable: true,
url:”initCoagencyTree.action”,
autoParam:[“id”, “name=n”],
otherParam:{“otherParam”:”zTreeAsyncTest”},
dataFilter: filter
},
// 简单多少格式
data: {
simpleData: {
enable: true
}
},
// 回调函数
callback: {
beforeClick: beforeClick,
onClick: onClick
}
};
// 鼠标事件
function beforeClick(treeId, treeNode, clickFlag) {
// 普通选中
if(clickFlag==1){
parent.document.getElementById(“coagencyId”).value=treeNode.id;
parent.document.getElementById(“parentId”).value=treeNode.pId;
parent.document.getElementById(“name”).value=treeNode.name;
$(“#coagencyId”).attr(“value”,treeNode.id);
$(“#parentId”).attr(“value”,treeNode.pId);
}else{
// 撤消选中 把值置空
$(“#coagencyId”).attr(“value”,null);
$(“#parentId”).attr(“value”,null);
}
return (treeNode.click != false);
}
// 鼠标解除节点的办法
function onClick(event, treeId, treeNode, clickFlag) {
// 私下认可实施的主意 显示节点的详细音信
parent.showCoagencyDetail();
}
// 异步加载需若是函数
function filter(treeId, parentNode, childNodes) {
if (!childNodes) return null;
for (var i=0; i<childNodes.length; i++) {
childNodes[i].name = childNodes[i].name.replace(/\.n/g, ‘.’);
}
return childNodes;
}
// 异步加载需借使函数
function beforeAsync(treeId, treeNode) {
return treeNode ? treeNode.level < 5 : true;
}
// 开端化树
$(document).ready(function(){
$.fn.zTree.init($(“#coagencyTree”),settingOther);
});
</SCRIPT>
<!– 树节点id –>
<s:hidden name=”coagencyForm.coagencyId” id=”coagencyId”/>
<!– 树节点 父id –>
<s:hidden name=”coagencyForm.parentId” id=”parentId”/>
<div class=”zTreeDemoBackground left”>
<ul id=”coagencyTree” class=”ztree” style=”height:
640px”></ul>
</div>

                                url: baseUrl + ‘system/department/add’,

复制代码 代码如下:

ztree–插件完成增加和删除改查demo(完整版)

 

                                    }

                var zTree = $.fn.zTree.getZTreeObj(“treeDemo”);

 

 

 

                        parentId: parentId

 

 

 

                zTree.selectNode(treeNode);

                                    parentId: parentId

 

                                        toastr.success(‘增多成功!’)

 

 

                        } else {

                if (treeNode.pId === null || treeNode.pId==0) {

                    }

                } else {

                } else if (newName.length >= 15) {

                        url: baseUrl + ‘system/department/delete’,

                    //更新节点名称数据在此之前的平地风波回调函数,並且依据重返值鲜明是否同意退换名称的操作

                }

                    data: {

            $(‘.ico_open’).remove();

                        }

 

 

 

 

 

 

                    addHoverDom: addHoverDom,

 

                },

                    return false;

 

 

 

                    removeTitle: “删除”,

                    toastr.error(‘节点名称不能够为空’)

 

                                me.ztree()

                var sid = treeNode.id;

 

 

 

                for (var i = 0, l = childNodes.length; i < l; i++) {

                    success: function (res) {

 

            //修改节点音讯

                        sid: sid,

 

            }

                            $.ajax({

 

                if (newName.length == 0) {

 

            //删除节点音讯

 

                        if (res.status == “0000”) {

 

 

                    dataFilter: filter  //用于对 Ajax
再次来到数据开始展览预管理的函数

 

 

 

 

                    childNodes[i].name =
childNodes[i].name.replace(/\.n/g, ‘.’);

 

 

                    var sObj = $(“#” + treeNode.tId + “_span”);

                    });

 

                },

 

 

                view: {

            var zNodes = date;

                        }

                    onClick: zTreeOnClick

                edit: {

 

 

                                },

                callback: {

                }

 

 

                        success: function (res) {

 

 

                }

                    if (treeNode.editNameFlag || $(“#addBtn_” +
treeNode.tId).length > 0) return;

                $.ajax({

 

 

 

 

 

                            + “‘ title=’增多单位’
onfocus=’this.blur();’></span>”;

                    }

                                type: “post”,

 

                }

 

                },

            };

 

 

 

 

                async: {

 

 

 

                },

                } else {

 

                                    if (res.status == “0000”) {

                    $.ajax({

                                }

 

                    toastr.error(‘节点名称无法以空格’)

                    beforeRemove: beforeRemove,

                }

                            var orgName = treeNode.name;

                        data: {

                            + “‘ title=’增添班组’
onfocus=’this.blur();’></span>”;

                            toastr.success(‘修改成功!’)

 

 

 

 

                } else {

            };

 

 

 

 

                        if (treeNode.name) {

 

 

                                    orgName: orgName,

                                    } else {

                                toastr.success(‘删除成功’)

 

                    return false;

 

            };

 

                }

                            } else {

var setting = {

                        var addStr = “<span class=’button add’
id=’addBtn_” + treeNode.tId

                    var btn = $(“#addBtn_” + treeNode.tId);

                            });

                    beforeRename: beforeRename,

                    var sids = [];

 

 

 

                check: {

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图