同时使用多列 JQuery 过滤器和带有多选选项的复选框选择

问题描述 投票:0回答:0

我正在尝试同时使用 JQuery 数据表中的两个功能。

  1. 每行前面的复选框,带有多选选项 https://datatables.net/extensions/select/examples/initialisation/checkbox.html。和
  2. 多列过滤器和搜索如下例 https://datatables.net/examples/api/multi_filter.html

我将两个代码加在一起,但它不起作用。这里可能有什么问题?

    // Setup - add a text input to each footer cell
    $('#example tfoot th').each(function () {
        var title = $(this).text();
        $(this).html('<input type="text" placeholder="Search ' + title + '" />');
    });
 
    // DataTable
    var table = $('#example').DataTable({
        initComplete: function () {
            // Apply the search
            this.api()
                .columns()
                .every(function () {
                    var that = this;
 
                    $('input', this.footer()).on('keyup change clear', function () {
                        if (that.search() !== this.value) {
                            that.search(this.value).draw();
                        }
                    });
                });
        },
         
        $(document).ready(function() {
    $('#example').DataTable( {
        columnDefs: [ {
            orderable: false,
            className: 'select-checkbox',
            targets:   0
        } ],
        select: {
            style:    'os',
            selector: 'td:first-child'
        },
        order: [[ 1, 'asc' ]]
    } );
} );
    });
});
javascript jquery datatable datatables-1.10
© www.soinside.com 2019 - 2024. All rights reserved.