What is the best way to repopulate a table from a JavaScript data source?

What is the best way to repopulate a table from a JavaScript data source?

gzarambogzarambo Posts: 7Questions: 2Answers: 0

I'm essentially looking for ajax.reload() without the ajax... unfortunately, I'm working in a system that uses web technology to a degree, but my data calls are handled in a proprietary method, so standard ajax is not an option for me.

My data does come in as a JavaScript object, so the initial creation of my DataTable is a snap, but I'm struggling with how to repopulate the table when I get a new set of data. I've considered 1) destroy()ing and re-initializing the table or 2) comparing the old data to the new and and adding/removing/updating rows, but both seem heavy-handed, especially when the ajax.reload() is so tantalizingly close to what I want. I've also thought of the possibility of overloading the ajax methods to call our proprietary ones, but thought I should make sure I'm not missing something easy before I go down that route.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,920Questions: 1Answers: 10,153 Site admin
    Answer ✓

    I'm essentially looking for ajax.reload() without the ajax...

    Use clear() followed by rows.add() - which is essentially all ajax.reload() does, just with a $.ajax call to get the data to add.

    Allan

This discussion has been closed.