2013-01-16 108 views
0

好吧,所以我有一個漂亮的標準動態數據表,但我似乎無法得到搜索框基於輸入或選擇框的值進行過濾。jQuery Datatables bSearchable過濾器輸入值

oTable = $('#itemTable').dataTable({ 
    "bJQueryUI": true, 
    "sPaginationType": "full_numbers", 
    "sDom": '<""f>t<"F"lp>', 
      "aoColumns": [ 
       { "sWidth": "45px", "bSearchable": false}, 
       { "sWidth": "150px"}, // <input type="text"> 
       { "sWidth": "150px"}, // <select> 
       { "sWidth": "150px"}, // <select> 
       { "sWidth": "125px"}, // <input type="text"> 
       { "sWidth": "75px", "bSearchable": false}, 
       { "sWidth": "75px", "bSearchable": false}, 
       { "sWidth": "75px", "bSearchable": false}, 
       { "sWidth": "75px", "bSearchable": false}, 
       { "sWidth": "75px", "bSearchable": false} 
      ], 

我怎樣才能獲得的數據表來過濾基於文本框的值的搜索結果,和/或一個選擇框的當前選擇的價值?

我發現這個jQuery DataTables - custom filter for column that contains text field但我似乎無法使這項工作對我來說

+0

我剛剛意識到我需要使用mDataProp ....這個問題是擱置,因爲我通過這個工作...... –

回答

1

我設法得到這個使用jquery-datatables-column-filter plugin jQuery的數據表工作

,一旦你有,你可以再補充.columnFilter()到您的數據表。關於這個插件的很大一部分是你可以使用數據表「aoColumns」正常和.columnFilter()只覆蓋特定的專欄中,我只是包含其他數據表中設置顯示這一點,見下面的例子:

var asInitVals = new Array(); 

$(document).ready(function() { 
    var oTable = $('#myTable').dataTable({ 
     "bPaginate": true, 
     "fnDrawCallback":function(){$('.edit').editable(function(value, settings) { 
          hasBeenEdited(this); 
          return(value); 
         }, { 
          type : 'text', 
          submit : 'OK' 
         });}, 

     "oLanguage": { 
      "sSearch": "Search all columns:", 
     }, 
     "aoColumns": [ 
         { "bSortable": true ,"bSearchable": true}, 
         { "bSearchable": true}, 
         {"bSortable": true , "bSearchable" : true}, 
         {"bSearchable": true }, 
         {"bSearchable": true }, 
         { }, 
         { } 
        ] 
    }).columnFilter({"aoColumns":[{ type: "select", values: [ 'Value 1', 'Value 2', 'Value 3'] }, 
     null, 
     null, 
     null, 
     null, 
     null, 
     null]}); 
}); 
0

你可以在aColumns中使用mRender屬性來指定篩選的選擇框的選定值

​​
相關問題