Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

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

$
0
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();
})

Viewing all articles
Browse latest Browse all 2364

Trending Articles