CSVHtml5 buttons fails when data is from JSON and some columns are not string.
CSVHtml5 buttons fails when data is from JSON and some columns are not string.
jorge33
Posts: 1Questions: 0Answers: 0
Source code: https://cdn.datatables.net/buttons/1.0.2/js/buttons.html5.js
I was debugging and in the line 305 of previous link.
for ( var i=0, ien=a.length ; i<ien ; i++ ) {
if ( i > 0 ) {
s += separator;
}
s += boundary ?
boundary + a[i].replace( boundary, '\\'+boundary ) + boundary :
a[i];
}
The a[i] is a field value from JSON data in datatable, So, when the a[i] is not a String, (For example a number), I get an error because a number doesnt have .replace function.
A simple fix could be to replace "a[i].replace" to "a[i].toString().replace" .
In my case, I just added and works.
This discussion has been closed.
Replies
Please update to the current 1.1.0 release which addresses this issue.
Allan