How to get data from all rows in paginated datatable?
How to get data from all rows in paginated datatable?

I'm using DataTables V1.5.0 and I am trying to get every unique data from all the rows but it is only returning data from the rows of first page. My implemented code is below.
$('#basicTable').DataTable({
...
initComplete: function () {
this.api().columns().every(function () {
let column = this
column.data().unique().sort().each( function (d) {
console.log(d)
})
})
}
})
Please point out what I'm doing wrong and also how to solve the issue. Any help would be appreciated. Thanks
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
To be clear: Table is server sided.
Yep, with
serverSide
, only the data on the page is known to the client, so that would be expected. Do you needserverSide
? How many records are in your data set?Colin
Yes. I do need serverSide option. There are only 300 records. Is there any change I can do at client side or even at server side to get all records?
With only 300 records you don't need the server side option enabled. This way all 300 records are returned to the client. Try removing or commenting out
serverSide: true
to see what happens.Kevin
By commenting out
serverSide
, I get all the data in the request but table gets stuck on loading and does not display any data. How can I solve this?Sounds like you are getting an error. Look at your browser's console.
Kevin
Thank you @kthorngren & @colin . This does solve the problem. This is my first time working with DataTables and I thought I had to change a lot of code to convert from server side to client side. But its fairly simple. Thanks again