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()+','
});
复制代码