我正在使用database
从dataTable
显示我的数据。但是Number of Entries
和Search
框无法正常工作。 Entries
与rows
的数量不匹配且Search
框无效。什么似乎是问题?
这是我的表
<table class="table table-striped table-bordered table-hover" id="dataTables-gatepass">
<thead>
<tr>
<th>
Consignee
</th>
<th>
Address
</th>
<th>
Broker Name
</th>
<th>
Carrying Aircraft
</th>
<th>
Registration No.
</th>
<th>
Date of Arrival
</th>
<th>
Exportation
</th>
<th >
PKG
</th>
<th >
Gross Weight
</th>
<th >
AWB/MAWB No.
</th>
<th >
HAWB No.
</th>
<th >
Action
</th>
</tr>
</thead>
<tbody>
<?php foreach ($results as $key){?>
<tr>
<td><?php echo $key['consignee'];?></td>
<td><?php echo $key['address1'].' '.$key['address2'];?></td>
<td><?php echo $key['broker'];?></td>
<td><?php echo $key['carrying_aircraft'];?></td>
<td><?php echo $key['reg_no'];?></td>
<td><?php echo $key['date_arrival'];?></td>
<td><?php echo $key['air_exportation'];?></td>
<td><?php echo $key['pkg'];?></td>
<td><?php echo $key['gross_weight'];?></td>
<td><?php echo $key['awb_mawb'];?></td>
<td><?php echo $key['hawb'];?></td>
<td>
<a target="_blank" href="<?php echo site_url('gatepass/gatepass_print?id='.$key['gatepass_ID']);?>"><button type="submit" class="btn btn-xs blue tooltips " title="print" data-container="body" data-placement="top" data-html="true"><i class="fa fa-print"></i></button></a>
</td>
<tbody></tbody>
</tr>
<?php } ?>
</tbody>
</table>
在我的外部js中
$(document).ready(function(){
$('#dataTables-gatepass').dataTable();
});
答案 0 :(得分:0)
$('#dataTables-gatepass').dataTable();
// #myInput is a <input type="text"> element
$('#myInput').on( 'keyup', function () {
table.search( this.value ).draw();
});
有关更多信息,请使用此链接https://datatables.net/reference/api/search()