【发布时间】:2014-07-08 19:40:42
【问题描述】:
我在 codeigniter 中有视图,我正在尝试使用数据表和 TableTools 扩展来增强它。我正在使用 1.94 版的数据表。根据R shiny dataTables with TableTools and other extensions 的说法,需要2.1.5 版的表格工具。我已经包括了这个。我正在尝试关注http://datatables.net/extensions/tabletools/ 和上面的文章以使 TableTools 正常工作,但到目前为止还没有 TableTools 工具栏的迹象。我做错了什么?
这是我的代码:
<table id="myDataTable">
<thead>
<tr>
<th>ROW</th>
<?php foreach($keys as $key): ?>
<th><?php echo $key; ?></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php $i=1; foreach($fulltable as $row): ?>
<tr id="<?php echo $i ?>">
<td><?php echo $i; ?></td>
<?php foreach($row as $cell): ?>
<td><?php echo $cell; ?></td>
<?php endforeach; ?>
</tr>
<?php $i++; endforeach; ?>
</tbody>
</table>
<!--jQuery-->
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
<!--DataTables CSS-->
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
<!--DataTables-->
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<!--DataTable tools-->
<script type="text/javascript" charset="utf8" src='//cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/js/TableTools.min.js'></script>
<script type="text/javascript" charset="utf8" src='//cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/js/ZeroClipboard.min.js'></script>
<link rel="stylesheet" type="text/css" href='//cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/css/TableTools.min.css'>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$('#myDataTable').dataTable( {
"dom": 'T<"clear">lfrtip',
"tableTools": {
"sSwfPath": "//cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/swf/copy_csv_xls.swf",
}
});
});
</script>
【问题讨论】:
标签: php jquery codeigniter datatable