EasyUI中Treegrid节点的删除

时间:2022-06-22 12:48:01

// 删除
function removes() {
    var rows = ruletreegrid.treegrid('getSelections');
    if (rows && rows.length == 1) {
        var showmsg = "";
        if (rows[0].pid == 0) {
            // 下面有子节点
            showmsg = "项目下面可能存在细则,是否也一起删除 ?";
        } else {
            showmsg = "是否删除此细则 ?";
        }
        parent.$.messager.confirm('提示', showmsg, function(r) {
            if (r) {
                $.ajax({
                    url : "assess/rule/ruleremoves/" + rows[0].id + ".do",
                    dataType : "json",
                    success : function(data) {
                        if (data && data.success) {
                            if (data.msg && data.msg != "")
                                parent.$.messager.alert('提示', data.msg);
                            else
                                parent.$.messager.alert('提示', "删除成功");
                            ruletreegrid.treegrid('remove', rows[0].id);
                            ruletreegrid.treegrid('reload', rows[0].pid);
                        } else {
                            parent.$.messager.alert('错误', data.msg);
                        }
                    }
                });
            }
        });
    } else {
        parent.$.messager.alert('提示', "请选择一条要删除的项目!");
    }
}