datatables
var table;
$(document).ready(function() {
table = $("#table").DataTable({
"language": {
"sProcessing": "处理中...",
"sLengthMenu": "每页_MENU_条 ",
"sZeroRecords": "没有匹配结果",
"sInfo": "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项",
"sInfoEmpty": "显示第 0 至 0 项结果,共 0 项",
"sInfoFiltered": "(由 _MAX_ 项结果过滤)",
"sInfoPostFix": "",
"sSearch": "搜索:",
"sUrl": "",
"sEmptyTable": "表中数据为空",
"sLoadingRecords": "载入中...",
"sInfoThousands": ",",
"oPaginate": {
"sFirst": "首页",
"sPrevious": "上页",
"sNext": "下页",
"sLast": "末页"
}
},
"aLengthMenu": [40, 100, 3000],
//"sAjaxSource": "find/all",
"ajax": {
url: "find/all",
error: function() {
window.location.href = "welcome";
}
},
"bProcessing": true,
//DataTables载入数据时,是否显示‘进度’提示
"bAutoWidth": false,
"bDeferRender": true,
"bLengthChange": true,
"bPaginate": true,
"bServerSide": true,
"bSort": false,
"deferRender": true,
"iDisplayLength": 10,
"searching": false,
//是否显示搜索框
"bFilter": true,
"bProcessing": true,
"order": [[1, 'asc']],
//"fnServerData": retrieveData,
"columns": [{
"data": null
},
{
"data": "kh",
"render": function(data, type, row, meta) {
return '' + data + '
';
}
}, {
"data": "sjrdh",
"visible": false
}]
});
table.on('draw.dt',
function() {
table.column(0, {
search: 'applied',
order: 'applied'
}).nodes().each(function(cell, i) {
//i 从0开始,所以这里先加1
i = i + 1;
//服务器模式下获取分页信息,使用 DT 提供的 API 直接获取分页信息
var page = table.page.info();
//当前第几页,从0开始
var pageno = page.page;
//每页数据
var length = page.length;
//行号等于 页数*每页数据长度+行号
var columnIndex = (i + pageno * length);
cell.innerHTML = columnIndex;
});
}).draw();
});
$("#find").click(function(){
var param = {
"date": $("#logmin").val(),
"khm": $("#khm").val()
};
table.settings()[0].ajax.data = param;
table.ajax.reload();
});