Problem in tabletools PDF export!
Problem in tabletools PDF export!
mhs
Posts: 2Questions: 0Answers: 0
Hi,
I've got the Datatables working on my site but I found there is an issue in Tabletools PDF generator:
When I click on PDF button, Tabletools just export the table title, no thing more!
[code]
function formatTime(value) {
var buf = [];
buf.push(String(Math.floor(value/3600)));
buf.push(':');
var x=value%3600;
if(x/60 < 10)
buf.push('0');
buf.push(String(Math.floor(x/60)));
buf.push('\'');
if(x%60 < 10)
buf.push('0');
buf.push(String(x%60));
buf.push('\"');
return buf.join("");
};
$(document).ready( function () {
$('#dynamic').html( '' );
var oTable = $('#example').dataTable({
"sDom": 'T<"clear">lfrtip',
"aaSorting": [],
"oTableTools": {
"sSwfPath": "swf/copy_cvs_xls_pdf.swf",
"sRowSelect": "multi",
"aButtons": [
"copy",
"csv",
"xls",
{
"sExtends": "pdf",
"sPdfOrientation": "portrait",
"sPdfMessage": "PhoneLogger call details"
},
"print","select_all", "select_none"
]
},
// "aaData": aDataSet,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": 'detail.json',//'/cgi-bin/phlog.cgi?id=l',//
"sServerMethod": "POST",
"aoColumns": [
{ "sTitle": "Name" },
{ "sTitle": "ID" , "sClass": "center"},
{ "sTitle": "No." },
{ "sTitle": "Date & Time" , "sClass": "center"},
{
"sTitle": "Duration",
"sClass": "center",
"fnRender": function(obj) {
var sReturn = parseInt(obj.aData[ obj.iDataColumn ],10);
return formatTime(sReturn);
}
}
],
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "IndexRec", "value": 0xffff } );
aoData.push( { "name": "IndexCounter", "value": 0 } );
$.post(sSource, aoData,function (json) {
fnCallback(json)
}, "json" );
}
} );
new FixedHeader( oTable );
} );
[/code]
I have tried DataTables Ver. 1.9.1 and Ver. 1.9.0 and both work as mentioned, but when I try this code by V1.8, it works well and all of data shown in PDF file.
For simplicity I wrote server response in a file to be checked without the need to server:
[code]
{"aaData":[
["Eric Smith ","003","66509296 ","11/07/2010 10:01","012"],
["Jack ","002","45645643 ","11/07/2010 10:02","022"],
[" ","003","8768752 ","11/07/2010 10:03","211"],
["Not Specified ","013","87767853 ","11/07/2010 10:04","045"],
["John Smith ","006","09122088395","11/07/2010 10:05","078"],
["Eric ","004","66505447 ","11/07/2010 10:06","004"],
["Eve ","003","76576884 ","11/07/2010 10:07","023"]
]}
[/code]
Any help appreciated.
I've got the Datatables working on my site but I found there is an issue in Tabletools PDF generator:
When I click on PDF button, Tabletools just export the table title, no thing more!
[code]
function formatTime(value) {
var buf = [];
buf.push(String(Math.floor(value/3600)));
buf.push(':');
var x=value%3600;
if(x/60 < 10)
buf.push('0');
buf.push(String(Math.floor(x/60)));
buf.push('\'');
if(x%60 < 10)
buf.push('0');
buf.push(String(x%60));
buf.push('\"');
return buf.join("");
};
$(document).ready( function () {
$('#dynamic').html( '' );
var oTable = $('#example').dataTable({
"sDom": 'T<"clear">lfrtip',
"aaSorting": [],
"oTableTools": {
"sSwfPath": "swf/copy_cvs_xls_pdf.swf",
"sRowSelect": "multi",
"aButtons": [
"copy",
"csv",
"xls",
{
"sExtends": "pdf",
"sPdfOrientation": "portrait",
"sPdfMessage": "PhoneLogger call details"
},
"print","select_all", "select_none"
]
},
// "aaData": aDataSet,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": 'detail.json',//'/cgi-bin/phlog.cgi?id=l',//
"sServerMethod": "POST",
"aoColumns": [
{ "sTitle": "Name" },
{ "sTitle": "ID" , "sClass": "center"},
{ "sTitle": "No." },
{ "sTitle": "Date & Time" , "sClass": "center"},
{
"sTitle": "Duration",
"sClass": "center",
"fnRender": function(obj) {
var sReturn = parseInt(obj.aData[ obj.iDataColumn ],10);
return formatTime(sReturn);
}
}
],
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "IndexRec", "value": 0xffff } );
aoData.push( { "name": "IndexCounter", "value": 0 } );
$.post(sSource, aoData,function (json) {
fnCallback(json)
}, "json" );
}
} );
new FixedHeader( oTable );
} );
[/code]
I have tried DataTables Ver. 1.9.1 and Ver. 1.9.0 and both work as mentioned, but when I try this code by V1.8, it works well and all of data shown in PDF file.
For simplicity I wrote server response in a file to be checked without the need to server:
[code]
{"aaData":[
["Eric Smith ","003","66509296 ","11/07/2010 10:01","012"],
["Jack ","002","45645643 ","11/07/2010 10:02","022"],
[" ","003","8768752 ","11/07/2010 10:03","211"],
["Not Specified ","013","87767853 ","11/07/2010 10:04","045"],
["John Smith ","006","09122088395","11/07/2010 10:05","078"],
["Eric ","004","66505447 ","11/07/2010 10:06","004"],
["Eve ","003","76576884 ","11/07/2010 10:07","023"]
]}
[/code]
Any help appreciated.
This discussion has been closed.
Replies
Button graphics (ie. csv.png, csv_hover.png, ...) were not shown!
Is it optional to use graphics instead of text labels for them? If so, what is that option?