use*_*790 37 javascript asp.net datatables
<script>
jQuery(document).ready(function () {
$('#sample_3 tfoot th').each(function () {
var title = $('#sample_3 thead th').eq($(this).index()).text();
$(this).html('<input type="text" placeholder="Search ' + title + '" />');
});
// DataTable
var table = $('#sample_3').dataTable();
// Apply the filter
table.columns().eq(0).each(function (colIdx) {
$('input', table.column(colIdx).footer()).on('keyup change', function () {
table
.column(colIdx)
.search(this.value)
.draw();
});
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
我得到table.columns不是函数js错误,缺少什么我不明白.
seb*_*n_k 128
尝试改变
var table = $('#sample_3').dataTable();
Run Code Online (Sandbox Code Playgroud)
至
var table = $('#sample_3').DataTable();
Run Code Online (Sandbox Code Playgroud)
......就是把资本化DataTable()
.资料来源:https://datatables.net/manual/api#Accessing-the-API
小智 31
更改:
table.columns()
Run Code Online (Sandbox Code Playgroud)
至:
table.api().columns()
Run Code Online (Sandbox Code Playgroud)
它对我有用.
我正在尝试使用dataTables的makeEditable()函数.如果我用DataTables()更改dataTables(),它就不起作用.
h0mayun的答案对我有用.以防万一其他人搜索这个问题我在h0mayun的评论中添加了一些东西.
var table = $('#sample_3').dataTable();
$('#sample_3 tfoot th').each(function (i)
{
var title = $('#sample_3 thead th').eq($(this).index()).text();
// or just var title = $('#sample_3 thead th').text();
var serach = '<input type="text" placeholder="Search ' + title + '" />';
$(this).html('');
$(serach).appendTo(this).keyup(function(){table.fnFilter($(this).val(),i)})
});
Run Code Online (Sandbox Code Playgroud)
并删除以下部分
// Apply the filter
table.columns().eq(0).each(function (colIdx) {
$('input', table.column(colIdx).footer()).on('keyup change', function () {
table
.column(colIdx)
.search(this.value)
.draw();
});
});
Run Code Online (Sandbox Code Playgroud)
希望它能帮助别人.
归档时间: |
|
查看次数: |
48311 次 |
最近记录: |