Retrieving data passed in to a datatable

Retrieving data passed in to a datatable

mbpmmbpm Posts: 1Questions: 1Answers: 0

Hi, sorry if this seems like an obvious question but all my attempts so far have been unsuccesful. After I create a datatable like so:

table = $("#report-table").DataTable({ data: dataSet, .....

I want to be able to retrieve the data that I passed in to the datatable 'data' property by querying the datatable itself. Is this information actually stored in the datatable or is it only used to construct the datatable? All my attempts have brought back the data in a different format from what was used as 'dataSet'. I have tried

$("#report-table").DataTable().rows().data()
$("#report-table").DataTable().data

with no success.

Do I have to store this information somewhere else on the DOM to be able to access it?

Thanks

Answers

  • kthorngrenkthorngren Posts: 21,302Questions: 26Answers: 4,947

    $("#report-table").DataTable().rows().data()

    This should work. It will return the data for all rows and the Datatables API. dataSet should be an array of either objects or arrays depending on our data structure. You should be able to access the array the same way using rows().data().

    Datatables keeps its own data cache, you don't need to store it anywhere else.

    All my attempts have brought back the data in a different format from what was used as 'dataSet'.

    Please provide more details regarding the source dataSet, what you are retrieving versus what you want to retrieve.

    Kevin

This discussion has been closed.