码迷,mamicode.com
首页 > 其他好文 > 详细

layui表格的批量删除功能

时间:2018-04-27 02:44:16      阅读:1237      评论:0      收藏:0      [点我收藏+]

标签:lin   选中   text   系统错误   data   color   index   test   table   

 1     // 批量删除功能
 2     // 1.得到table选中行内容
 3     // 2.得到删除需要的唯一值,一般是id;
 4     // 3.将所要删除的项加入到数组中;
 5     // 4.判断是否选中;
 6     // 5.发送ajax请求,并附带参数id;
 7      var $=layui.$,active={
 8          deLink:function () {
 9              var checkStatus=table.checkStatus(‘idTest‘),
10                  data=checkStatus.data,
11                  deList=[];
12              data.forEach(function(n,i){
13                  delList.push(n.id);
14              });
15              if(delList!=‘‘){
16                  layer.comfirm(‘确定删除所选项吗?‘,function (index) {
17                      $.ajax({
18                          url: ‘/cd/workPlatform/tool/remove.afca‘,
19                          type:‘post‘,
20                          dataType:‘json‘,
21                          data:"id="+delList,
22                          success:function (data,statusText) {
23                              if(data.code===‘0‘){
24                                  layer.msg(‘删除成功‘);
25                                  table.reload(‘idTest‘,{});
26                              }else{
27                                  layer.msg(‘删除失败‘);
28                              }
29                          },
30                          ‘error‘:function () {
31                              layer.msg(‘系统错误‘);
32                          }
33                      })
34                  })
35              }else{
36                  layer.tips(‘请选择需要删除的行‘,$(‘#batchDel‘),{
37                      tips:[3,‘#5fb878‘]
38                  })
39              }
40          }
41      }

 

layui表格的批量删除功能

标签:lin   选中   text   系统错误   data   color   index   test   table   

原文地址:https://www.cnblogs.com/yangguoe/p/8955445.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!