首页 > 代码库 > EasyUI treegrid 删除一条或多条记录

EasyUI treegrid 删除一条或多条记录

        function del_dg() {
            $.messager.defaults = { ok: "是", cancel: "否" };
            var node = $(‘#tbClientClass‘).treegrid(‘getSelected‘);
            //单条记录删除
            if (node != null) {
                $.messager.confirm(‘系统提示‘, ‘<br/>确定要删除吗 ? ‘, function (r) {
                    if (r) {
                        //删除部门信息
                        $.post(‘/ashx/Client/tbClientClass.ashx?action=del&pid=‘ + node.pid, function (msg) {
                            msgShow(‘系统提示‘, ‘<br/>删除成功 !‘, ‘info‘);
                            $(‘#tbClientClass‘).treegrid(‘reload‘);
                        });
                    }
                });
            } else {
                msgShow(‘系统提示‘, ‘请选择要删除的记录! ‘, ‘error‘);
            }

            /////// 多选删除
            if (node) {
                var nodes = $(‘#tbClientClass‘).treegrid(‘getChildren‘, node.pid);
            } else {
                var nodes = $(‘#tbClientClass‘).treegrid(‘getChildren‘);
            }
            var s = ‘‘;
            for (var i = 0; i < nodes.length; i++) {
                if (s != ‘‘)
                    s += ‘,‘;
                s += nodes[i].id;
            }
            if (node) {
                if (s != ‘‘)
                    s += ‘,‘;
                s += node.id;
                $.messager.confirm(‘系统提示‘, ‘删除节点将同时删除其下面所有节点,您确定要删除吗?‘, function (r) {
                    if (r) {
                        //删除部门信息
                        $.post(‘/ashx/Client/tbClientClass.ashx?action=del&pid=‘ + s, function (msg) {
                            msgShow(‘系统提示‘, ‘删除成功‘, ‘info‘);
                            $(‘#tbClientClass‘).treegrid(‘reload‘);
                        });
                    }
                });
            } else {
                msgShow(‘系统提示‘, ‘请选择要删除的部门‘, ‘error‘);
            }

        }

  

EasyUI treegrid 删除一条或多条记录