What is the best way to completly reload a DataTable?
What is the best way to completly reload a DataTable?
nuno
Posts: 14Questions: 0Answers: 0
Hi!
I have a DataTable that is created after a request to the server using the "sAjaxSource".
I would like to periodically call the server and reload the latest response updating the table. I would like to have the table updated or rebuilt without it disappearing and also that the user sorting options would be kept.
What would be the best approach?
Thx in advance :)
I have a DataTable that is created after a request to the server using the "sAjaxSource".
I would like to periodically call the server and reload the latest response updating the table. I would like to have the table updated or rebuilt without it disappearing and also that the user sorting options would be kept.
What would be the best approach?
Thx in advance :)
This discussion has been closed.
Replies
Use the modified fnReloadAjax() API call in that thread. The modification is to get / set the scrollTop() of the table so that on each reload it remembers the previous scroll position.
Thanks a lot Taylor! :)
For example, I'm using the details row feature which means I add a column to the table containing the expansion controls. This is done within the fnInitComplete callback.
When I then call the fnReloadAjax() function I would assume datatables knows about it but it doesn't...
I had to manually remove the details column:
[code]
reload:function(){
$j('th:first-child, td:first-child').remove()
oTable.fnReloadAjax()
FL.create_details_col()
},
[/code]
I've also had to given up the rows grouping because it doesn't work well together with sorting and the details rows...
So, I'd say it's quite good but not yet fantastic...