数据表个别列筛选不起作用


Datatables individual column filtering not working

感谢Stryner编写的代码如何禁用数据表上特定列的搜索/筛选器?

这正是我想要的。

但是,如果底部TH单元格确实在需要的地方显示输入,在模糊/更改/键上,什么都不会发生。。。

控制台:未定义不是一个函数-对应于"oTable.columns().eq(0).each(function(colIdx){"

你能帮我解决这个问题吗?

谢谢你:))

$('#datos tfoot th').not(":eq(0),:eq(3),:eq(5),:eq(6)") //Exclude columns 0, 3, 5 and 6
                     .each( function ()
                      {
                      var title = $('#example thead th').eq( $(this).index() ).text();
                      $(this).html( '<input type="text" placeholder="Rechercher" />' );
                     });
   var oTable = $('#datos').dataTable();
   oTable.columns().eq( 0 ).each( function ( colIdx ) {
    if (colIdx == 0 || colIdx == 3 || colIdx == 5 || colIdx == 6) return; //Do not add event handlers for these columns
    $( 'input', table.column( colIdx ).footer() ).on( 'keyup blur change', function () {  oTable
                                                                                          .column( colIdx )
                                                                                          .search( this.value )
                                                                                          .draw();
                                                                                        });
}); 

我的服务器端脚本与daniweb.com/web-development/php/threads/4467455/convert-datatables-to-server-side-processing 页面底部的脚本相同

感谢

请在您的keyup事件中尝试此操作,并让我知道它是否有效。我很久以前就用过这个了,所以不能确定它是否适合你,但也许它有帮助:

$("tfoot input").keyup( function () {
        /* Filter on the column (the index) of this element */
        oTable.fnFilter( this.value, $("tfoot input").index(this) );
    } );