How to reload data from AJAX and keep table DOM elements for unchanged rows?

How to reload data from AJAX and keep table DOM elements for unchanged rows?

noobernoober Posts: 2Questions: 2Answers: 0

Hi,

I've tried ajax.reload() and it seems though there is no actual changes in a row, its DOM is completely rebuild. For instance, CSS .selected class disappear. Is there a way to use internal cache and compare new row data against previous row to decide if <TR> should or shouldn't be replaced at all?

Thank you.

Answers

  • allanallan Posts: 62,312Questions: 1Answers: 10,225 Site admin

    Unfortunately there is no built in method to do that 'diff' in DataTables at the moment. A reload, as you say will destroy all of the old rows and replace with new.

    A plug-in method could be created that will make the Ajax request and then use row.add(), row().data() and row().remove() as required,but it is not something that I currently have. If you create one, I'm sure others would be interested if you could share it (I know I would :-) ).

    Allan

This discussion has been closed.