簡體   English   中英

jQuery數據表按文本過濾

[英]Jquery datatable filter by text

我正在使用以下代碼從jquery數據表中過濾記錄。我的數據表格式是這樣的

 var aDataSet = [['1', 'GOld', 'G-110,G-112,G-123', 'G1-001,G1-005,G1-008'],
                ['2', 'GOld type 1', 'G1-001,G1-003,G-123', 'G-110,G-112,G-156']];


 $(document).ready(function () {
                oTable = $('#example').dataTable();
                oTable.fnFilter('G-110,G-112');
            });

假設我將上述功能的輸入值賦予'G-110,G-112'意味着輸出是這樣的

顯示以上兩個記錄。

假設我的輸入是G1-001,G1-003,G-156表示僅顯示第二條記錄。

我想過濾數據表行中存在的大部分項目。

您必須在fnFilter function包括對regexp檢查:

fnFilter函數將以下元素作為parameter s:

  • {string}:用於過濾行的字符串
  • {int | null}:將過濾限制為的列
  • {bool} [default = false]:是否視為正則表達式
  • {bool} [default = true]:是否執行智能過濾
  • {bool} [default = true]:在其輸入框中顯示輸入的全局過濾器
  • {bool} [default = true]:不區分大小寫的匹配是(true)或不是(false)

因此您的過濾器功能應如下所示:

oTable.fnFilter('G-110,G-112',null,true); 
//this will check your row based on regular expression also.

暫無
暫無

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

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