Empty table and reload Json data
Empty table and reload Json data
atiqul
Posts: 2Questions: 1Answers: 0
My use case is that once I receive data from server side, I need to massage data (add a tags, classes, and the like) before I can add it to the table.
I can remove all data by using $("#example tbody").empty(); then I can use t.add().row([array]);
but this is slow also need to fix pagination
Is there a shortcut to that to empty table, add rows and adjust pagination?
Thanks,
-AI
This discussion has been closed.
Answers
Can you show me the full code you are using please? I might be able to spot how it can be optimised.
Allan
var tbl = $('#example').DataTable();
//clear table
tbl.rows().remove().draw(false);
//add row one at a time
tbl.row.add([ "Gavin Cortez", "Team Leader", "San Francisco", "2860", "2008/10/26", "$235,500" ]).draw(false);
If you are calling
draw()
every time you userow.add()
, then that's going to hurt performance a lot! Add all of the rows (presumably in a loop) and then usedraw()
.Allan