Migrating to 2.0.0
Migrating to 2.0.0
Hi,
I read about the fact that the legacy function fnServerData it's no longer available in the last 2.0.0 version.
The question is, is there a way to use something similar?
In my use case, in the previous versions, I was able to use that function to call a rest api service and fill the table using the fnCallback({iTotalRecords, iTotalDisplayRecords, aaData})
Now I've tried to use the option ajax, as a function that do the same stuff, but I don't know exactly how to give back the data to the dataTables (fnCallback is undefined)
Some idea?
This question has accepted answers - jump to:
Answers
Yes, use
ajax
as a function. It is more or less the same thing (ajax
as a function has been in since 1.10 in 2014!).Allan
Sorry - I missed this bit. The callback function is passed into your own function. I've called in
callback
in the documentation, but you could name it anything you want:Note that the names of the parameters for the returned data have also been changed, see the docs here.
There is some more discussion about this in the 1.10 upgrade notes - note that the
legacy.ajax
option isn't available in 2 any more (although it would be fairly easy to map parameters across if you needed to).Allan
Thank you @allan!
I noticed the params changes after I wrote this post, so now I'm using the ajax option as function and it seems to works.
have a nice day
Hi @allan
I have one doubt, I'm still using
{iTotalRecords, iTotalDisplayRecords, aaData}
as the param object of the callback (I'm using pagination)
Do you think it's right?
Or maybe there's a newer object shape to pass?
You will probably want to use the current parameter names as described in the Server Side Processing protocol docs.
Kevin
Yup, the old parameter names from before 1.10 have now been removed in 2. Time to update them
Allan