我在数据表中获取数据,但我想要数据加载数据。
$('#userdata').DataTable({
"ajax" : "/searchuser1?emp="+emp,
"bDestroy":true,
"columns":[
{"data": "empid1"},
{"data": "name"},
{"data": "phone"},
{"data": "logintime"},
{"data": "logouttime"}
],
"order": [[ 1, "desc" ]],
"language": {
"lengthMenu": "| View _MENU_ records per page",
"zeroRecords": "Nothing found - sorry",
"infoEmpty": "No records available",
"infoFiltered": "(filtered from _MAX_ total records)"
},
"pagingType": "full_numbers",
"lengthChange": false
});
我尝试了以下方式,但我不知道它在数据表中写入了什么
var totalRecords =$("#userdata").DataTable().page.info().recordsTotal;
alert(totalRecords);
答案 0 :(得分:0)
试试这个,
$('#userdata').DataTable({
"ajax" : "/searchuser1?emp="+emp,
"bDestroy":true,
"columns":[
{"data": "empid1"},
{"data": "name"},
{"data": "phone"},
{"data": "logintime"},
{"data": "logouttime"}
],
"order": [[ 1, "desc" ]],
"language": {
"lengthMenu": "| View _MENU_ records per page",
"zeroRecords": "Nothing found - sorry",
"infoEmpty": "No records available",
"infoFiltered": "(filtered from _MAX_ total records)"
},
"pagingType": "full_numbers",
"lengthChange": false
});
//By methods
function getCount(){
var totalRecords =$("#userdata").DataTable().page.info().recordsTotal;
alert(totalRecords);
}
答案 1 :(得分:0)
Datatable有inbuild函数来获取这样的长度
change this
'post_type' => 'array ('episodes')',
to
'post_type' => 'episodes',
or
'post_type' => 'array ("episodes")',