<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
oTable = $('#example').dataTable({
"oLanguage" : { // 汉化
"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": "末页"
}
},
"bPaginate" : true,// 分页按钮
"bFilter" : false,// 搜索栏
"bLengthChange" : true,// 每行显示记录数
"iDisplayLength" : 20,// 每页显示行数
"bSort" : false,// 排序
"bInfo" : true,// Showing 1 to 10 of 23 entries 总记录数没也显示多少等信息
"bAutoWidth" : true, // 自动计算列宽度
"sPaginationType" : "full_numbers", // 分页,一共两种样式 另一种为two_button // 是datatables默认
"bProcessing" : true,
"bServerSide" : true,
"sAjaxSource" : "getMeterData.action",
"fnServerData" : function(sAjaxSource, aoData, fnCallback) {
//aoData.push( { "name": document.getElementById("start").value, "value": document.getElementById("end").value } );//添加自己的额外参数
var start = $("#start").val();
var end = $("#end").val();
if(typeof JSON == 'undefined'){
$('head').append($("<script type='text/javascript' src='mis01/js/json2.js'>"));
}
$.ajax({
"type" : 'post',
"url" : sAjaxSource,
"dataType" : "json",
"data" : {
"start" : start,
"end" : end,
aoData : JSON.stringify(aoData)
},
"success" : function(resp) {
fnCallback(resp);
console.log(resp)
}
});
},
});
} );
</script>
$('#example tbody').on( 'click', 'tr', function () {
if ( $(this).hasClass('selected') ) {
$(this).removeClass('selected');
}
else {
table.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
}
} );
datatable详细参数配置
最新推荐文章于 2024-04-08 17:19:41 发布