DEV*_*DEV 6 javascript datatable jquery
我已经包含了此链接中的代码:https://datatables.net/examples/api/multi_filter.html
但它不能正常工作.搜索框显示但在搜索框中键入详细信息时数据无法加载.我将发布我已包含在我的文件中的代码.请仔细看看并验证相同.
任何帮助将不胜感激.谢谢.
码
<div class="col-md-12" style="max-height:300px; display:block; overflow:auto;" >
<table id="big_table" class="table table-striped display table-bordered">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
<th>Column 5</th>
<th>Column 6</th>
<th>Column 7</th>
<th>Column 8</th>
<th>Column 9</th>
<th>Column 10</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
<th>Column 5</th>
<th>Column 6</th>
<th>Column 7</th>
<th>Column 8</th>
<th>Column 9</th>
<th>Column 10</th>
</tr>
</tfoot>
<tbody>
<?php foreach($array as $arr) { ?>
<tr>
<td><?php echo $arr->column_1; ?></td>
<td><?php echo $arr->column_2; ?></td>
<td><?php echo $arr->column_3; ?></td>
<td><?php echo $arr->column_4; ?></td>
<td><?php echo $arr->column_5; ?></td>
<td><?php echo $arr->column_6; ?></td>
<td style="text-align:right;"><?php echo $arr->column_7; ?></td>
<td style="text-align:right;"><?php echo $arr->column_8; ?></td>
<td><?php echo $arr->column_9; ?></td>
<td><?php echo $arr->column_10; ?></td>
</tr>
<?php } ?>
</tbody>
Run Code Online (Sandbox Code Playgroud)
JAVASCRIPT
<script>
$(document).ready(function() {
// including input
$('#big_table tfoot th').each( function () {
var title = $(this).text();
$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
} );
// datatable initialization plus exporting to excel
var table = $('#big_table').DataTable( {
dom: 'Bfrtip',
buttons: [
'excelHtml5'
],
"bFilter": false,
"bInfo": false,
} );
//search
table.columns().every( function () {
var that = this;
$( 'input', this.footer() ).on( 'keyup change', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
.draw();
}
} );
} );
} );
</script>
Run Code Online (Sandbox Code Playgroud)
Luc*_*cky 11
看起来像bFilterdatatable init部分中的属性正在使数据表的冲突不可搜索.根据datatables站点,如果要单独搜索多个列,则应将此属性设置为true.尝试以下代码进行数据表初始化,
var table = $('#big_table').DataTable( {
dom: 'Bfrtip',
buttons: [
'excelHtml5'
],
"bInfo": false,
} );
Run Code Online (Sandbox Code Playgroud)
这应该适合你.检查这个JSFIDDLE
如果要使数据表全局搜索过滤器被禁用(隐藏),则应将dom设置为lrtp.例如:dom: 'lrtp'
| 归档时间: |
|
| 查看次数: |
11432 次 |
| 最近记录: |