Return Additional Data in JSON and Access in Callback

Return Additional Data in JSON and Access in Callback

rosinscjrosinscj Posts: 8Questions: 0Answers: 0
edited March 2014 in General
we are using: jQuery.fn.dataTableExt.oApi.fnDataTablesPipeline (https://datatables.net/examples/server_side/pipeline.html) to retrieve data from the server.

Is there a way to return additional data to be used in a callback?

[code]
//from the server
$jsonDataArray = array(
'sEcho' => $sEcho
'aaData' => $data,
'additionalKey' => 'someValue'
);
$jsonData = json_encode($jsonDataArray);
[/code]

In the fnDrawCallback (or some other callback), is there a way to access 'additionalKey'? I was unable find that key in oSettings or any other value passed into the various callbacks.

The answer provided in links below don't quite answer the question, since they aren't using pipelining to retrieve information:
http://stackoverflow.com/questions/6090260/jquery-datatables-return-additional-information-from-server
http://datatables.net/forums/discussion/5854/how-to-returning-morecustom-data-from-server-side-script-and-displaying/p1

Thank you,

Chris

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    In DataTables 1.10 you can use the `ajax.json()` method ( http://next.datatables.net/reference/api/ajax.json() ). In 1.9- you'd need to use fnInitComplete and access the JSON data that way (second parameter).

    Allan
  • rosinscjrosinscj Posts: 8Questions: 0Answers: 0
    I've attempted to use fnInitComplete, however the json parameter is undefined. I believe is this due to using server side processing, since the ajax call is after the datatable finishes it's initialization.
This discussion has been closed.