Trying to get the IDs of the records across all the pages

Trying to get the IDs of the records across all the pages

FrankyDoulFrankyDoul Posts: 2Questions: 1Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem: I am trying to get the id of the entire datatset that is passed to AJAX, and display it in an array on the page, in a way that the array refreshes everytime the page reload. I have the following code:

$ ->
$('#people-pr-datatable').dataTable
processing: true
order: []
serverSide: true
drawCallback: ->
people_ids = @api().rows().data().map (people) -> people.DT_RowId
$("#filtered-data").html people_ids.join()
console.log(this.fnSettings().fnRecordsTotal());
ajax: data: (d) ->
d.url = $('#people-pr-datatable').data('source');

i am able to display the ids of only the current page in the filtered-data div. But i would like to display all the ids of my table i if possible. What would be the right way please ?

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • FrankyDoulFrankyDoul Posts: 2Questions: 1Answers: 0

    Hi Colin,
    I am trying to build the test case, but I do not know how to do that with an AJAX Datatable please.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Do you mean the id's of the data shown in the rows of the table? If so, note that you have server-side processing enabled (serverSide). That means that only the rows currently visible in the table (i.e. the current "page") are available at the client-side.

    If you want the id's for all rows, regardless of the page they would be shown on with the DataTable, you'd need to use client-side processing (i.e. remove the serverSide option).

    Regarding a test case, if you can't link to your own page, the second page Colin linked to contains a number of templates including Ajax, which you could use to create a test case from.

    Allan

Sign In or Register to comment.