gpt4 book ai didi

javascript - 如何在引导数据表中插入列过滤器

转载 作者:行者123 更新时间:2023-11-28 05:41:27 25 4
gpt4 key购买 nike

我已经将我的 html 表与数据表绑定(bind)在一起,搜索、分页和排序等功能运行良好。但是当我尝试使用

实现列过滤器时
$('#table1').DataTable().columnFilter();`

这不起作用。它显示一个错误,指出

columnFilter is not a function.

最佳答案

我用不同的方式做到了。

$('#demo-dt-basic thead tr th').each(function (i) {        
var title = "Search "+$(this).text();

$("<input class='form-control input-sm' type='text' placeholder='" + title + "'/>").appendTo($(this));
table.columns().eq(0).each(function (colIdx) {
$('input', table.column(colIdx).header()).on('keyup change', function () {
table
.column(colIdx)
.search(this.value)
.draw();
});
});

} );

关于javascript - 如何在引导数据表中插入列过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38888498/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com