Return custom variables from server side to datatables ajax call
Return custom variables from server side to datatables ajax call
Hi,
I would like to return some non table data from my server-side datatable back to the browser.
https://datatables.net/manual/server-side specifies what I must return(data, recordsTotal, recordsFiltered, etc..) and has some other options like row classes. But how can I add my own variable to the response.
e.g. ryansCustomVariable
and then access this - Iwas going to try getting it in "drawCallback: function(settings){....ryansCustomVariable}"
(Why? I would like to set some info above the table with JQuery. I can calculate the info from the result of the db call in the server side code.)
Ryan,
p.s. I really love the 1.10 api! so clean and easy to use! Thanks
This question has an accepted answers - jump to answer
Answers
I've been playing with this all afternoon and after reading about the server-side options and writing my own server-side query I clocked that the way to go was to use the
"dataSrc"
of the"ajax"
object. Basically you'll need to remember to return your data to the datatable but you can listen to whatever you want in there:Hope that that helps.
Thanks a million @annoyingmouse - it works!!