How can i make table.ajax.reload(callback,resetflag) Synchronus.
How can i make table.ajax.reload(callback,resetflag) Synchronus.

I want to maintain row selection even after making table.ajax.reload(callback,false). Callback function has logic to highlight selected row. But in my case callback is getting executed before table refresh. As a result unable to maintain row selection after reload.
This question has accepted answers - jump to:
This discussion has been closed.
Answers
If you're using just arrays as the data sources (as opposed to objects, where you can use the
rowId
), then you can use this example I just created. All it does is wait forselect
anddeselect
, then save the row indexes, then when the table is re-drawn (via the ajax reload), it re-selects them all.However, I ran into a problem with this... I had it setup so you could delete an "item" from the table, it would send the ajax call to delete the item, then just reload the table via
ajax.reload()
, the problem I ran into, is if rows were selected, then when the other rows that got deleted were removed (which were above the selected row(s)), the indexes all got changed, so when the table reloaded, different rows were selected...So, in short.. use objects in your ajax data source, then it should work just fine, (example here)
By the way.. that 2nd example I sent you, I didnt find that until I replied to your comment...
I ran into the same problem you had, because event though I was using objects in my data source, I didnt specify the
rowId
, so I created my own way of doing it...And now that I see it was all pointless, had I just seen that example I linked you... I hate myself for not looking harder >.< lol
Yup - if you are using the Select extension for your row selection, then it should actually be handled automatically - as long as the
rowId
option is used to specify a unique id for each row (this will work for arrays as well as objects - DOM sourced data as well if you happen to then want to replace it with Ajax sourced data).Allan
Thanks for your responses. But i am using version 1.10.7 and it is giving me an error of
Object doesn't support property or method 'ids' When i try select as an extension.
Upgrade your datatables
Yes - as the documentation for
rows().ids()
notes, that method was introduced in 1.10.8. 1.10.9 is the current release.Allan
Thanks everyone. I upgraded to 1.0.9 and with some tweaks i got what i wanted.