DataTables recordsTotal: 0 while recordsFiltered: more than 0
DataTables recordsTotal: 0 while recordsFiltered: more than 0
I'm having a bit of trouble, I'm using DataTables but some tables doesn't seen to fetch the results from the DB. A couple of tables show this in the PHP: {draw: 1, recordsTotal: 0, recordsFiltered: 3, data: []} data: [] draw: 1 recordsFiltered: 3 recordsTotal: 0
While the DataTable itself show this: Showing 1 to 3 of 3 entries (filtered from 0 total entries)
I don't know why those two tables have issues while the other work, I checked plenty of times if there is a wrong variable but is all fine.
This question has an accepted answers - jump to answer
Answers
Looks like you have server side processing enabled, ie,
serverSide: true
. Your server script is in control of the data returned and responsible for providing the proper information insrecordsTotal
,recordsFiltered
, etc as described in the Server Side Processing docs. The values ofrecordsTotal: 0, recordsFiltered: 3
aren't correct asrecordsTotal
should be all the records in your DB table.Are you using a Datatables provided server side script?
Kevin
Yes, this is what I have in the JS
Like I said, I don't have problem with my other tables so I don't understand the error here.
And here is the PHP:
Just guessing but it looks like these are backwards:
Seems like it should be this:
Kevin
Thank you Kevi, but I still have the problem just in the opposite. The DT show now : Showing 0 to 0 of 0 entries (filtered from 3 total entries)
While the PHP show:
draw: 1, recordsTotal: 3, recordsFiltered: 0, data: []}
data: []
draw: 1
recordsFiltered: 0
recordsTotal: 3
Looks like you aren't returning any data. I would start by debugging the SQL statement built in your script to validate it.
Kevin
Thank you, I will do that.
did you fix this problem already bro? im having this problem also
Is this already solved? I'm also looking for the answer of this.