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()+','
     });
複製代碼
相關文章
相關標籤/搜索