Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82288

Refresh data (JSON) from server source -- keep open rows open

$
0
0

I've got a parent/child dataset presenting nicely.

The data does however change frequently. So I thought I'd fetch it from the server (a deeply nested JSON object) and pass in the updated data to the table and call draw:

if ($('#containerTable') && $('#containerTable').DataTable().rows().length > 0 && $('#containerTable').DataTable().rows()[0].length > 0) {
    var table = $('#containerTable').DataTable();
    table.data = providerList;
    table.draw();
    return;
}

If I don't have any rows then I go ahead and build the whole table again.

I'd do that anyway, except that I'd like to keep any expanded rows (containing a child table) open after the refresh (quality user experience and all that).

But the above doesn't actually refresh the data. Although I think it repaints the table.

Aside from trying to use ajax.reload() (which I'd do except that the JSON contains more than just the table contents) how might I go about updating the table's data?


Viewing all articles
Browse latest Browse all 82288

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>