Reputation: 1201
I am trying to render some fields before exporting to excel in my function I am doing like this;
"tableTools": {
"sSwfPath": "assets/global/plugins/data-tables/tabletools/swf/copy_csv_xls_pdf.swf",
"aButtons": [ {
"sExtends": "xls",
"sButtonText": "Excel",
"fnCellRender":function(sValue,iColumn,nTr,iDataIndex){
console.log(sValue);
//console.log($(sValue));
return sValue;
}
}, {
"sExtends": "print",
"sButtonText": lang.L_PRINT,
"sInfo": lang.L_PRINT_DESC,
"sMessage": "Metrics"
}]
}
So when I uncomment
console.log($(sValue));
it returns just first and second column which doesn't include any html tag inside. But when it finds a value that have html tag it stops.
ex - this gets the valu
<td class=" sorting_1">201408</td>
this doesn't
<span style="text-align:right;display:block;width:100%">121.25</span>
How can I fix it ?
Upvotes: 0
Views: 688
Reputation: 23
To troubleshoot this I found it much easier to just write the data into the CSV and see the format so I could then choose how to parse.
When you use the fnCellRender
property TableTools will not do any parsing of the HTML anymore. I would expect that you would see the raw data in the console window some of which would be HTML I assume and others just values.
When it's HTML you can use JQuery to extract the values or a regular expression. E.g
if ($(sValue).prop("checked")) {
return "TRUE";
} else {
return "FALSE";
}
or in your case
return $(sValue).val();
Some research I used:
TableTools background and good discussion with links
Upvotes: 1