dataTable 批量删除

ajax 异步
var tab;
$(function(){
	   var serverNum=localStorage.getItem("servernum");
	   $("#newVersion").attr("data-id",serverNum)
	   var key=$("#key").val()||"";
	   tab = $('#dataTables').DataTable({
	        "pagingType": "simple_numbers",//设置分页控件的模式
	        searching: true,//展开datatales的查询框
	       // aLengthMenu: [10],//设置一页展示10条记录
	        "bProcessing": false,
	        "ordering": false,
	        "bLengthChange": true,//展开tables的一页展示多少条记录的下拉列表
	        "showRefresh": true, //是否显示刷新按钮  
	        "oLanguage": { //对表格国际化
	            "sLengthMenu": "每页显示 _MENU_条",
	            "sZeroRecords": "暂无数据!",
	            "bProcessing": false,
	            "sInfo": "当前第 _START_ - _END_ 条 共计 _TOTAL_ 条",
	            "sInfoEmpty": "",
	            "sInfoFiltered": "(从 _MAX_ 条记录中过滤)",
	            "sSearch": "搜索:",
	            "sSearchPlaceholder": "搜索...",
	            "oPaginate": {
	                "sFirst" : "首页",
	                "sPrevious" : "«",
	                "sNext" : "»",
	                "sLast" : "尾页"
	            }
	        },
	        "processing": false, //打开数据加载时的等待效果
	        "serverSide": false,//打开后台分页
	        "ajax": {
	            "url": "admin/getGiveFoodList",
	            "dataSrc": "data",
	            'dataType': 'jsonp',
	            'jsonp': "callback",
	            'type': 'get',
	            "data": function (d) {
	            	console.log(d)
	                //d.serverNum=serverNum; 
	            /*    d.orderStatus=orderStatus; 
	               d.payStatus=payStatus;  */
	            }
	        },
	        //<input type="checkbox" class="ace"><span class="lbl"></span>
	        "columns": [
				 {"data": "gfId", "title": "<input type='checkbox' class='ace' id='checkAll'><span class='lbl'></span>", "defaultContent": "","render": function (data, type, row) {
		            	 return "<input type='checkbox' class='ace' value='"+row.gfId+"'><span class='lbl'></span>";	
			      }}, 
	                    {"data": "orderId", "title": "订单编号", "defaultContent": "","createdRow": function( row, data, dataIndex ) {
	  	            	  return "<text style='max-width: 300px; overflow: hidden;text-overflow: ellipsis; '> </text> ";
	  	            	}
	  	            },  
	            {"data": "deskId", "title": "桌号", "defaultContent": "","createdRow": function( row, data, dataIndex ) {
	            	  return "<text style='max-width: 300px; overflow: hidden;text-overflow: ellipsis; '> </text> ";
	            	}
	            },  
	            {"data": "productName", "title": "菜品名", "defaultContent": "","createdRow": function( row, data, dataIndex ) {
	            	  return "<text style='max-width: 300px; overflow: hidden;text-overflow: ellipsis; '> </text> ";
	            	}
	            },  
	            {"data": "categoryName", "title": "菜品分类", "defaultContent": "","createdRow": function( row, data, dataIndex ) {
	            	  return "<text style='max-width: 300px; overflow: hidden;text-overflow: ellipsis; '> </text> ";
	            	}
	            }, 
	            {"data": "wName", "title": "服务员名", "defaultContent": "","createdRow": function( row, data, dataIndex ) {
	            	  return "<text style='max-width: 300px; overflow: hidden;text-overflow: ellipsis; '> </text> ";
	            	}
	            },
	            {"data": "gfAddtime", "title": "操作时间", "defaultContent": "","createdRow": function( row, data, dataIndex ) {
	            	  return "<text style='max-width: 300px; overflow: hidden;text-overflow: ellipsis; '> </text> ";
	            	}
	            },
	           /*  {"data": "gfId", "title": "操作", "defaultContent": "","render": function (data, type, row) {
		             
			          return" <a href=\"javascript:;\"  onclick=\"member_del(this,'"+ row.gfId+"')\" title=\"删除\" class=\"btn btn-xs btn-warning\" ><i class=\"fa fa-trash  bigger-120\"></i></a>";		        
			      }
	            }, */
	   ]
	        
	  });
	  //复选框选择
	   $('table th input:checkbox').on('click' , function(){
			var that = this;
			$(this).closest('table').find('tr > td:first-child input:checkbox')
			.each(function(){
				this.checked = that.checked;
				$(this).closest('tr').toggleClass('selected');
			});
				
		});	   
})
//获取已经选中的复选框
 $.each($('input:checkbox:checked'),function(){
        s+=$(this).val()+','
     });
复制代码

转载于:https://juejin.im/post/5c4c20226fb9a049e7027b4f

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值