Using an [ajax] Custom Get Function? Don't forget to set sAjaxDataProp !!
Using an [ajax] Custom Get Function? Don't forget to set sAjaxDataProp !!
Documentation for ajax.dt in the API really needs an addition noting sAjaxDataProp !!
If you are using the 'ajax' property as a function (so that you can control how the parameters get sent to the server and process what comes back before DT gets at it) then you MUST set sAjaxDataProp to the name of the data object array in the json structure that you pass to the callback !!!
If you do not do this then DT cannot find your data object array, (it will not matter that you have named it 'data' as you think you are supposed to, or even 'aaData' as indicated elsewhere)
Do yourself a favor and set sAjaxDataProp to the name of your data object array !!
I found this using the most excellent DT Debugger !!
This question has an accepted answers - jump to answer
Answers
The
ajax.dataSrc
option replaces sAjaxDataProp in 1.10 if you are using theajax
option. sAjaxDataProp should not be required.Allan
I was setting ajax = function
I tried adding ajax.dataSrc both before and after that setting and it didn't seem to matter
I am trying again, since I was flailing about a bit and can't be sure I tried this properly
Ah yes, if you use
ajax
as a function, then you are expected to return the data array to the callback function. Thanks for the clarification.Allan
yes, but therin lies the rub (as my dear old dad used to say,) when I returned the data array then the table had data but the pagination numbers didn't work -- and when I returned the json structure then the pagination numbers worked but the data was missing from the table.
the only option that worked was to set sAjaxDataProp and return the json structure
Odd. Are you using server-side processing? That might explain it... There could be a bug there if so.
Allan
yes, server side processing
cool, I might get a bug named after me !!
Yes, just confirmed - this is a bug. I'll look into it for the next release. Thanks for letting me know about this.
Allan
you are welcome - I'm alway happiest when I'm using DT because it's so capable and complete!!