其他分享
首页 > 其他分享> > 批量删除

批量删除

作者:互联网

开发工具与关键技术:Visual Studio 2015,C# 
作者:谢天林 
撰写时间:2019年05月20日

批量删除是一个基本功能,他可以方便客户操作,加深客户的体验。

先把数据渲染出来:在这里插入图片描述
书写要执行的功能代码:

//批量删除考生信息
     function delStudents() {
        //获取选中行数据
        var checkStatus = layuiTable.checkStatus('tabStudent');
        if (checkStatus.data.length>0) {
        var studentIDs = "";
        for (var i = 0; i <checkStatus.data.length; i++) {
             studentIDs += checkStatus.data[i].studentID + ";";
        //拼接字符串  9617;9611;split(;)}
        //去掉最后的一个“;”
        //substring() 方法用于提取字符串中介于两个指定下标之间的字符。
        //substring(start,stop) 方法返回的子串包括 start 处的字符,但不包括 stop 处的字符。[0,studentIds.length-1)
        studentIDs = studentIDs.substring(0, studentIDs.length - 1);

         layer.confirm("您确定要删除选中的" + checkStatus.data.length + "条学生信息?", { icon: 3, title: "提示" }, function () {
         $.post("delStuInfos", { StudentIds: studentIDs }, function (msg) {
         layer.alert(msg, { icon: 0, title: "提示" });
           tabStudent.reload();
          })
         })
          } else {
                layer.alert("请选择需要删除的数据");
            }
      }

完成批量删除功能:在这里插入图片描述

(注:代码来源于学习过程)

如有错漏,感谢纠正!

标签:批量,删除,代码,客户,checkStatus,var
来源: https://blog.csdn.net/weixin_44538322/article/details/90441381