【问题标题】:How to set default data in data table multiple page如何在数据表多页中设置默认数据
【发布时间】:2020-01-20 08:31:26
【问题描述】:

我对数据表中的默认设置有疑问。 我希望在控制器端选中复选框。 我发现在第二页之后检查的复选框不起作用。

 function cteate_table() {
    var newRow = ''
    $('#main-table').dataTable()
    $('#main-table').dataTable().fnClearTable()
    for (var i = 0; i < 100; i++) {
        newRow += '<tr>'
        newRow += '<td>'
        newRow += i
        newRow += '</td>'
        newRow += '<td>'
        newRow += i + i + ' ' + '100'
        newRow += '</td>'
        newRow += '<td>'
        newRow += '<input type="checkbox" id="ch_"+i  name="ch_"+i>'
        newRow += '</td>'
        newRow += '</tr>'
        table = $('#main-table').DataTable();
        table.rows.add($(newRow)).draw();
    }
}

<table class="table table-bordered" id='main-table'>
   <thead>
      <tr class="thead_table">
         <th class="thead_id_list">index</th>
         <th class="thead_id" >example</th>
         <th class="thead_id2">Operation</th>
      </tr>
   </thead>
   <tbody>
   </tbody>
</table>

【问题讨论】:

    标签: javascript php html datatable


    【解决方案1】:

    为什么 $('#main-table').dataTable() 在函数中出现多次。检查一下!

    【讨论】:

    • 应该是评论
    猜你喜欢
    • 1970-01-01
    • 2019-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-20
    • 1970-01-01
    • 2021-11-01
    • 1970-01-01
    相关资源
    最近更新 更多