What is the equivalent of ajax.reload() for local (non-ajax) data in 1.10.x?
What is the equivalent of ajax.reload() for local (non-ajax) data in 1.10.x?
I'm using a local variable to hold the data for an instance of DT. This variable changes, gets rows added, deleted, whatever... Reading the api, the solution seems to be .rows().invalidate().draw(). However, this doesn't work:
http://jsfiddle.net/5vzet7oa/1/
Curiously though if I remove #3 completely and replace it with tdata[0].foo = "a"; tdata[0].bar ="b".... it works. No clue why that works, but it doesn't solve my problem with when I would need to push() or pop() data in my local variable. So what is the magic recipe that would allow me to do something akin to ajax.reload() but on a local variable? I.e. I need the entire cache cleared and whatever is currently in the local var to be re-drawn. The only thing I can see that works is to .destroy() the table first and then re-initialize the whole thing. That seems rather inelegant though when the user will be doing alot of changes.
Answers
Use
clear()
androws.add()
.The
rows().invalidate()
method is used to invalidate the cached data for the existing rows. It does not take account of new or removed rows.Allan