问题
I am trying to use the newest tableTool 2.2.0 and i have made a little and simple example jsfiddle.net/9ZTGb/
COPY and PRINT buttons seems to respond, but the "Copy" is resulting "blank", and "CSV","Excel","PDF" seems not workinkg at all..
this is the table:
<table id="tblExport" class="table table-condensed">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Larry</td>
<td>Smith</td>
<td>@lsmith</td>
<td>Approved</td>
</tr>
<tr>
<td>2</td>
<td>Mark</td>
<td>Williams</td>
<td>@mwills</td>
<td>Pending</td>
</tr>
<tr>
<td>3</td>
<td>Jeremy</td>
<td>Jones</td>
<td>@jj</td>
<td>Success</td>
</tr>
<tr>
<td>4</td>
<td>Carlos</td>
<td>Martin</td>
<td>@cmar</td>
<td>Suspende</td>
</tr>
</tbody>
</table>
and this is the js script:
$(document).ready(function () {
$('#tblExport').dataTable({
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "https://datatables.net/release-datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf",
"aButtons": ["copy", "csv", "xls", "pdf", "print"]
}
});
});
I would really appreciate if someone could tell me why it isn't working. the example here and the jsfiddle i tried to make as simple as possible, but still not really working..
回答1:
sSwfPath : Flash file Security is the Issue:
Solution:
Step 1: Check For sDom Property.
Step 2: Check the SWF Path is correct. If its correct
Step 3: Open Flash Manager :
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
Under 3rd Tab, Global Settings Add the Site Url Which contains SWF Path. Select Always Allow Option.
Then Try the Save PDF By Refresh.
回答2:
An answer to getting the Copy/CSV/Excel/PDF buttons working is provided here.
Essentially, a cdn library is referenced instead of the local swf file. Change your swf path code to:
"tableTools": {
"sSwfPath": "//cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf"
}
This, along with the standard initialization, worked for me.
回答3:
Maybe it would be useful. I implemented extention just for exoprting tables in csv format without using flash: https://github.com/zedxter/DataTablesCSV
来源:https://stackoverflow.com/questions/23222554/datatables-tabletools-buttons-not-working-correctly-simple-example