jQuery DataTable与页脚没有响应

时间:2016-05-03 09:36:31

标签: jquery html twitter-bootstrap css3 datatables

当我在表格中添加tfoot时,表格无法响应

我遵循这个例子 https://datatables.net/examples/api/multi_filter.html

当我只有文本的页脚然后响应时,但是何时输入页脚然后没有响应

HTML:

<div class="row">
<div class="col-sm-12">
    <h2>Persons</h2>
</div>
<div class="col-sm-12">
<table id="tblPersons" class="table display table-hover table-striped userTables" >
<thead>
    <tr>
        <th>ID</th>
        <th>Name</th>
        <th>Email</th>
        <th>Telephone</th>
    </tr>
</thead>
<tfoot>
    <tr>
        <th>ID</th>
        <th>Name</th>
        <th>Email</th>
        <th>Telephone</th>
    </tr>
</tfoot>
<tbody>

JS:

$('#tblPersons thead th').each( function () {
    var title = $('#tblPersons tfoot th').eq($(this).index()).text();
    $(this).html('<input type="text" class="form-control" placeholder="Search '+title+'" />');
});

var table=$("#tblPersons").DataTable({
    bSort:true,
    bPaginate:true,
    bFilter:true,
    bInfo:false,
    //"bLengthChange": false,
    responsive:true
});

table.columns().eq(0).each( function ( colIdx ) {
    $( 'input', table.column( colIdx ).header() ).on( 'keyup change', function () {
        table.column( colIdx ).search( this.value ).draw();
    });

    $('input', table.column(colIdx).header()).on('click', function(e) {
        e.stopPropagation();
    });
});

1 个答案:

答案 0 :(得分:4)

尝试输入液体:

#tblPersons input {
    width: 100%;        
    box-sizing: border-box;
}