I'm trying to enable server-side processing for data-tables and searching/sorting/chaning amount of rows work, everything except pagination
The setup for datatables is like this:
$('[data-table]').each(function() {
var url = $(this).data("table");
$(this).DataTable({
"processing": true,
"serverSide": true,
"ajax": {
url: url,
type: 'POST'
}
});
})
Server side, the response looks like this:
{
data: […]
draw: "12"
recordsFiltered: 10
recordsTotal: "208"
}
And the funny thing is, if I ommit recordsFiltered
and recordsTotal
pagination work (kinda, last dosent work, but the rest does)... check these images:
您只有10行,因此只有1页就没有分页。
"recordsTotal" and "recordsFiltered" should be the same value. So, if you have 160 total records in your table or query, yo should set the same value to the "recordsFiltered" parameter.
This is a common misunderstanding, according to the docs. What the docs says and i think we all understand is that we should filter the records and set the "recordsFiltered" this count.
"Total records, after filtering (ie the total number of records after filtering has been applied - not just the number of records being returned for this page of data)."
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.