簡體   English   中英

數據表單個列過濾不起作用

[英]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/467455/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) );
    } );

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM