Extend default button action - excel/excelHtml5
Extend default button action - excel/excelHtml5
I'm using the excel export button with no issue but I would like to extend it to add an additional behavior. Essentially, I'd like for it to do the excel export AND make an ajax call to a server file so it can record what data was exported. I tried using the code below, but when I specify an action it overrides the default action instead of extending it. How can I extend the action to perform the excel export and the ajax call?
buttons: [ 'copy',
{
extend: 'excelHtml5',
exportOptions: {
modifier: {
selected: true
}
},
action: function (e, dt, node, config ){
var url = '[my url ]';
var params = '';
jQuery.ajax({
dataType: 'html',
type: 'POST',
evalScripts: true,
url: url,
data: params
});
}
}]
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
Hi,
There isn't actually a good way of getting this information in the current release I'm afraid. However, I can absolutely see how this would be useful, so I've just committed a change that adds a new
customizeData
option to theexcel
buttons types and that can be used to be notified of the data used for the export. For example:Regards,
Allan
Allan, that's awesome! Thanks for the mod. I've download the latest build and will try this out today. Hopefully others will find it useful.