是这样加载的
var datatable;
function initDatatable() {
datatable = $('.datatable')
.DataTable(
{
"dom" : '<"top"i>rt<"bottom"flp> <"clear">',
"searching" : false,
"processing" : false,
"serverSide" : true,
"select" : true,
"ordering" : true,
"aLengthMenu" : [ [ 10, 20 ], [ 10, 20 ] ],
"language" : {
"url" : "${base}/assets/plugins/datatables/cn.json"
},
"preDrawCallback" : function() {
sublime.showLoadingbar($(".main-content"));
},
"drawCallback" : function() {
sublime.closeLoadingbar($(".main-content"));
},
"ajax" : {
"url" : "${base}/clerk/cloud/report/data",
"type" : "post",
"data" : function(d) {
d.name = $('#name').val();
d.phone = $('#phone').val();
d.join_time_begin = $('#join_time_begin')
.val();
d.join_time_until = $('#join_time_until')
.val();
}
},
"order" : [ [ 1, "desc" ] ],
"columns" : [
{
"data" : null,
"bSortable" : false
}, {
"data" : "name",
"bSortable" : false
}, {
"data" : "delivery_text",
"bSortable" : false
}, {
"data" : function(e) {
if (e.sex == 0) {
return '男';
} else {
return '女';
}
},
"bSortable" : false
},{
"data" : "phone" ,
"aSortable" : false
},{
"data" : "orderAll",
"aSortable" : false
},{
"data" : "orderFinish",
"aSortable" : false
},/*{
"data" : "distance",
"aSortable" : false
} ,*/{
"data" : "orderCancel",
"aSortable" : false
},{
"data" : "orderError",
"aSortable" : false
}
]/* ,
"columnDefs" : [ {
"render" : function(data, type, row) {
if (data) {
return moment(parseInt(data * 1000))
.format("YYYY-MM-DD HH:mm:ss");
}
return '';
},
"targets" : [ 14 ]
} ] */
});
datatable.on('order.dt search.dt', function() {
datatable.column(0, {
search : 'applied',
order : 'applied'
}).nodes().each(function(cell, i) {
cell.innerHTML = i + 1;
});
}).draw();
}
function initDatetimepicker(){
$('.form_datetime').datetimepicker({
language: 'zh-CN',
format:'yyyy-mm-dd ',
minView: "month",
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
forceParse: 0,
showMeridian: 1
});
}
$(function() {
initDatatable();
$('#join_time_begin').datetimepicker({ //日期选择框
format : 'yyyy-mm-dd',
language : 'zh-CN',
weekStart : 1,
todayBtn : 1,
autoclose : 1,
todayHighlight : 1,
startView : 2,
forceParse : 0,
minView : 2,
showMeridian : 1
});
$('#join_time_until').datetimepicker({ //日期选择框
format : 'yyyy-mm-dd',
language : 'zh-CN',
weekStart : 1,
todayBtn : 1,
autoclose : 1,
todayHighlight : 1,
startView : 2,
forceParse : 0,
minView : 2,
showMeridian : 1
});