我正在尝试使用TableTools将数据表(示例)导出到excel或csv中,我更喜欢Excel.但是使用下面的代码,它甚至没有显示我的图标(export/print/csv/..)我做了几处更改,但没有任何帮助..我究竟做错了什么?我错过了什么?有任何如何实现它的例子?我也完全像在官方网站上那样做,但仍然无法正常工作.
<link rel="stylesheet" type="text/css" href="assets/jquery.dataTables.css">
<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.0/css/jquery.dataTables.css">
Run Code Online (Sandbox Code Playgroud)
<!-- DataTables -->
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.0/js/jquery.dataTables.js"></script>
Run Code Online (Sandbox Code Playgroud)
$.ajax({
type: "POST",
url: "server_processing_harigot.php",
data: {
str: str,
hotel_id: hotel_id
},
cache: false,
success: function(result) {
data = JSON.parse(result);
$.each(data, function(index, data) {
//!!!--Here is the main catch------>fnAddData
$('#example').dataTable().fnAddData([
data.phone_number,
data.name,
data.client_id,
data.employee
]);
});
}
});
$('#example').dataTable({
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "swf/copy_csv_xls_pdf.swf"
}
});Run Code Online (Sandbox Code Playgroud)
<table width="100%" id="example" class="display" cellspacing="0">
<caption><strong> example </strong>
</caption>
<thead>
<tr>
<th>phone_number</th>
<th>name</th>
<th>client_id</th>
<th>employee</th>
</tr>
</thead>
<tbody id="tablebody">
</tbody>
</table>Run Code Online (Sandbox Code Playgroud)
任何的想法?
| 归档时间: |
|
| 查看次数: |
51100 次 |
| 最近记录: |