如何在同一頁中使用數據表,我使用模板數據表,但是當我創建新的數據表時不起作用。如何在同一頁面使用2個數據表?
這裏是我的代碼
CSS:
<link href="<?php echo base_url();?>/assets/plugins/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css"/>
<link href="<?php echo base_url();?>/assets/plugins/datatables/buttons.bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="<?php echo base_url();?>/assets/plugins/datatables/responsive.bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="<?php echo base_url();?>/assets/plugins/datatables/scroller.bootstrap.min.css" rel="stylesheet" type="text/css"/>
的JavaScript:
<!-- Datatable js -->
<script src="<?php echo base_url();?>/assets/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="<?php echo base_url();?>/assets/plugins/datatables/dataTables.bootstrap.js"></script>
<script src="<?php echo base_url();?>/assets/plugins/datatables/dataTables.buttons.min.js"></script>
代碼: 不,當我創建這個數據表新的所有功能不起作用。 。
echo "<table id='datatable-buttons' class='table display2 table-striped table-bordered'>";
echo "<thead>";
echo "<tr>";
echo "<th>No.</th>";
echo "<th>Itemset</th>";
echo "<th>Jumlah</th>";
echo"</tr>";
echo "</thead>";
echo "<tbody>";
foreach ($item_array as $ia_key => $ia_value)
{
//$theitems = explode('|',$ia_key);
for($x = 0; $x < count($ia_key); $x++)
{
if (($ia_value>=$support))
{
$no++;
echo "<tr>";
echo "<td> $no </td>";
echo "<td> $ia_key </td>";
echo "<td> $ia_value </td>";
$z++;
echo "</tr>";
}
}
}
echo "</tbody>";
echo "</tr>";
echo "</table>";
我可以看到你在初始化數據表JS ? –
[文檔](https://www.datatables.net/examples/basic_init/multiple_tables.html)不起作用? – Tpojka
您需要確保您的表格具有唯一標識 – Bindrid