How do I set an existing datatable's data to a javascript array I just fetched?

How do I set an existing datatable's data to a javascript array I just fetched?

cougarkevincougarkevin Posts: 7Questions: 4Answers: 0

I have a json on a server that contains data for a number of components including one datatable. When this json get's loaded, I want to set the datatables data and have it draw. I can make it work by making a separate ajax call just fine. But I would really prefer to just fetch the json (which can be big) once.

Separate Ajax Call

table.ajax.url(dataset_url).load().draw().columns.adjust().responsive.recalc();     

What I really want to do.

var jqxhr = $.get( dataset_url, function(data) {
    // set the data of other components on screen
    ...
    // load the table data
    table.data = data.data
    table.draw().columns.adjust().responsive.recalc();     
})

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.