table.columns不是datatable.js中的函数 [英] table.columns is not a function in datatable.js

查看:169
本文介绍了table.columns不是datatable.js中的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





 < 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();

//应用过滤器
table.columns()。eq(0).each(function(colIdx){

$('input',table.column(colIdx).footer())。on('keyup change',function(){

table
.column(colIdx )
.search(this.value)
.draw();
});
});

});
< / script>

我得到了table.columns不是js函数错误,缺少的是我不明白。 / p>

源: https://datatables.net/examples/api/ multi_filter.html

解决方案

尝试更改

  var table = $('#sample_3')。dataTable(); 

  var table = $('#sample_3')。DataTable(); 

...也就是说,将 DataTable()。来源: https://datatables.net/manual/api#Accessing-the-API


<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>

I got table.columns is not a function js error , what is missing i am not understand.

source : https://datatables.net/examples/api/multi_filter.html

解决方案

Try changing

var table = $('#sample_3').dataTable();

to

var table = $('#sample_3').DataTable();

... that is, capitalize the DataTable(). Source: https://datatables.net/manual/api#Accessing-the-API

这篇关于table.columns不是datatable.js中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆