Replicate the ajax request inside button action
Replicate the ajax request inside button action
Hello,
I have a serverSide implementation of a datatable and would like to build a custom excel export. In the datatable I've got an column search as well as an global search. There are also additional 3rd party search modifiers that are all passed into the ajax POST request and works seemleasly.
However, for my custom excel export, I would need to recreate this request and add additional needed params. Is ist possible to access/replicate the datatable ajax request with all its payload?
example code
var table = new DataTable('#example', {
processing: true,
serverSide: true,
ajax: { // the request would contain column infos / search, order, regex... etc
url: '/ssp/server_processing.php',
type: 'post',
data: (d) => {
d.additionl3rdPartyQuery = 'example 3rd party additional param' ,
},
},
});
buttons:[
{
text: 'Export button',
action: function ( e, dt, button, config ) {
// help needed here :
// do the ajax again but add another param to it
// maybe:
dt.ajax.data[] = { newParam : 'newParamData' }
dt.ajax.send
}
},
]
This question has an accepted answers - jump to answer
Answers
I think the plugin referenced in this FAQ is what you are looking for. You may need to modify the plugin to support the additional parameters.
Kevin
It is exactly it! I wont be needing the plugin, but the source code is enough to understand what I need to do. Thank you very much for your reply!
For anyone wondering, I'll be getting the params with
and doing with them as I see fit!
Thanks again Kevin!