Set datatable.data()

Set datatable.data()

CronosSCronosS Posts: 2Questions: 2Answers: 0

Hi,

What would be the best way to get & set the data of the whole table?
I'm looking for something like this, and wish that could be possible:

//set the initial datatable
var table = $('#example').DataTable();

//add some rows
table.rows.add([...])

//store the whole data for later use
var oldData = table.data();

//add some more rows
table.rows.add([...]);

//and here is what I'm looking for, restore the whole data to a previous state
table.data(oldData);

Answers

  • jr42.gordonjr42.gordon Posts: 305Questions: 2Answers: 49

    I use the below two lines of code to wipe my table and load it with new data.

    table.clear();
    table.rows.add( data ).draw();
    
This discussion has been closed.