How to implement Serverside Export to Excell ?
How to implement Serverside Export to Excell ?
I believe I am missing something, probably the mapping of data is all out of wack. However the pdf export works fine but when I do "copy,csv ,export to excell" the data shows the number of rows but the data is not there but the header seems to come out fine.
jQuery.fn.DataTable.Api.register('buttons.exportData()', function (options) {
if (this.context.length) {
var jsonResult = $.ajax({
type: "POST",
//datatype: "html5",
url: "/Home/GetData/?CheckDate=' + $("#EventDates option:selected").val(),
success: function (result) {
},
async: false
});
var a = jsonResult.responseJSON;
return { body: jsonResult.responseJSON, header: $("#tblPayroll thead tr th").map(function () { return this.innerHTML; }).get() };
}
});
Answers
I have not received any Reply so just wondering .
That's a clever hack to get around the export data not being available at the client-side.
Can you link to a test case showing the issue which will hopefully let me see and help debug the issue.
Allan
Allan the application I am was building is for proprietary data I will not be able to share that particular one but if you want i can build something just for the purpose of this and put it in a github repo for you to look into please let me know if that sounds okay.
I am running into this problem too. I would love to get a resolution. Has anyone figured this on out yet?
Thanks :-)
I found the solution the return of the body has to be changed from:
to:
I found this on the following blog:
https://diogenesggblog.wordpress.com/2017/02/02/how-to-export-all-rows-from-datatables-using-server-side-ajax/
In the comments section. Tried it and it work!