DataTable can't reload correctly after ajax load
DataTable can't reload correctly after ajax load
Hello everybody,
for a project in our company I work with DataTables on a Ruby-On-Rails-development.
We use an empty HTML table and set DataTables on top of this table.
On the initializing of the DataTables we make an server-side ajax call with an empty ajax url to just initialize the DataTable.
After that based on a form with default values (the user can updated these values) we set the ajax url for the DataTable with X.ajax.url(here comes our url).load()
.
The load does the trick to load the data and show this data in the table.
To show the table correctly on mobile views we call X.responsive.recalc()
.
There might be a bug or a timing problem because the recalc is done before the data are there so the empty table is recalced responsive and after that the data arrive and the table breaks the space of the mobile view.
Is there a bug in DataTables or am I just doing something wrong? Maybe I have to do something else or on another way to archive the recalc AFTER the data are fully load.
Can someone please help me?
Replies
Hi StefanKSK,
No, it's not a bug,
ajax.url().load()
just requires a callback for once that data has loaded. To do that, take a nose at this example .Hope that gets you up and running,
Cheers,
Colin
Hi colin,
Thank you very much for your help!
You pushed me in the right direction to solve my problem
For everyone who uses bootstrap panels with datatables:
For a view on mobile devices you can fix the overflow over a panel with
recalc()
after the load.