Table Tools doesn´t export pdf using fnCellRender and tabs
Table Tools doesn´t export pdf using fnCellRender and tabs
![ibanfr](https://secure.gravatar.com/avatar/84fe8059780e049f5e333217b6cc994a/?default=https%3A%2F%2Fvanillicon.com%2F84fe8059780e049f5e333217b6cc994a_200.png&rating=g&size=120)
Hello,
I'm using datatables within jquery ui tabs and I use table tools plugin to export table data as CSV, and PDF files.
In addition I use fnCellRender to pre-process the data of the table before exporting it, so I can export the values of the html inputs included in datatables.
I see this post:
http://datatables.net/forums/discussion/3783/issue-with-tabletools-2.0-on-hidden-tabs#Form_Comment
and I use the code suggested in this tutorial:
http://iksela.tumblr.com/post/3445022287/using-jquery-ui-tabs-and-datatables-tabletools
but the pdf exporting isn't working on hidden tabs. Pdf button is clickable but nothing happens when I click on it. csv and copy buttons works ok.
I think the problem is related with fnCellRender option, because if I remove this option form the code the pdf exporting works ok, but in this case I can´t export the input fields content.
Here is the initialisation code of one of my tables:
[code]
var oTableObjMensual = $('#listado_mensual').dataTable({
"bInfo":false,
"bFilter":false,
"aaSorting": [],
"bPaginate":false,
"bAutoWidth": false,
"sDom": '<"clear">lfrtip<"pie"T>',
"oTableTools": {
"aButtons": [
{"sExtends": "copy", "sButtonText": "<?= literal("Copiar");?>","sButtonClass": "botones_pie", "mColumns": "all"},
{"sExtends": "xls","sButtonClass": "botones_pie", "sTitle": "<?= literal("Objetivo Mensual");?>", "mColumns": "all","fnCellRender": contenido_exportarDatatable} ,
{"sExtends": "pdf","sButtonClass": "botones_pie","sPdfOrientation": "landscape", "sTitle": "<?= literal("Objetivo Mensual");?>","sPdfSize": "tabloid","mColumns": "all",
"fnCellRender": function ( sValue, iColumn, nTr, iDataIndex ) {
var valueExport = "";
var data = $(sValue)[0];
var tag = data.tagName;
if(tag==='SPAN'){
valueExport = data.innerHTML;
}else if(tag==='INPUT'){
valueExport = data.value;
}
return valueExport;
}
}
],
"sSwfPath": "/jquery/plugins/DataTables-1.9.4/extras/TableTools-2.1.4/media/swf/copy_csv_xls_pdf.swf"
},
"oLanguage": {
"sUrl": "/jquery/plugins/DataTables-1.9.4/language/es_ES.txt"
}
[/code]
If anyone know the solution please help me.
I'm using datatables within jquery ui tabs and I use table tools plugin to export table data as CSV, and PDF files.
In addition I use fnCellRender to pre-process the data of the table before exporting it, so I can export the values of the html inputs included in datatables.
I see this post:
http://datatables.net/forums/discussion/3783/issue-with-tabletools-2.0-on-hidden-tabs#Form_Comment
and I use the code suggested in this tutorial:
http://iksela.tumblr.com/post/3445022287/using-jquery-ui-tabs-and-datatables-tabletools
but the pdf exporting isn't working on hidden tabs. Pdf button is clickable but nothing happens when I click on it. csv and copy buttons works ok.
I think the problem is related with fnCellRender option, because if I remove this option form the code the pdf exporting works ok, but in this case I can´t export the input fields content.
Here is the initialisation code of one of my tables:
[code]
var oTableObjMensual = $('#listado_mensual').dataTable({
"bInfo":false,
"bFilter":false,
"aaSorting": [],
"bPaginate":false,
"bAutoWidth": false,
"sDom": '<"clear">lfrtip<"pie"T>',
"oTableTools": {
"aButtons": [
{"sExtends": "copy", "sButtonText": "<?= literal("Copiar");?>","sButtonClass": "botones_pie", "mColumns": "all"},
{"sExtends": "xls","sButtonClass": "botones_pie", "sTitle": "<?= literal("Objetivo Mensual");?>", "mColumns": "all","fnCellRender": contenido_exportarDatatable} ,
{"sExtends": "pdf","sButtonClass": "botones_pie","sPdfOrientation": "landscape", "sTitle": "<?= literal("Objetivo Mensual");?>","sPdfSize": "tabloid","mColumns": "all",
"fnCellRender": function ( sValue, iColumn, nTr, iDataIndex ) {
var valueExport = "";
var data = $(sValue)[0];
var tag = data.tagName;
if(tag==='SPAN'){
valueExport = data.innerHTML;
}else if(tag==='INPUT'){
valueExport = data.value;
}
return valueExport;
}
}
],
"sSwfPath": "/jquery/plugins/DataTables-1.9.4/extras/TableTools-2.1.4/media/swf/copy_csv_xls_pdf.swf"
},
"oLanguage": {
"sUrl": "/jquery/plugins/DataTables-1.9.4/language/es_ES.txt"
}
[/code]
If anyone know the solution please help me.
This discussion has been closed.