我正在使用jQuery數據表1.10並試圖搜索和篩選表。我想使用一個搜索文本框來搜索兩列和一個複選框來過濾第三列的結果。這裏是我的數據表:搜索jQuery數據表
var url = '@Url.Action("SupportClass1Search", "SupportClass1")';
$('#SupportClass1DataTable').DataTable({
"serverSide": true,
"processing": true,
"ajax": url,
"ordering": true,
"dom": '<"top"prl<"clear">>t<"bottom">pi<"clear">',
"pageLength": 10,
"autoWidth": false,
"columns": [
{ // create a link column using the value of the column as the link text
"data": "SupportClass1Id",
"width": "20%",
"render": function (oObj) { return "<a href='#' onclick='editItem(\"" + oObj + "\")'>" + oObj + "</a>"; },
},
{ "data": "SupportClass1Name", "sWidth": "70%" },
{ // convert boolean values to Yes/No
"data": "Active",
"width": "7%",
"render": function (data, type, full) {
if (data == true)
{ return 'Yes'; }
else
{ return 'No'; }
}
}
]
})
我想根據複選框值篩選第三列(活動)。下面的JS工程,以過濾表,但不拾取激活列當我輸入「是」或「否」:這樣
// use an outside search input
oTable = $('#SupportClass1DataTable').DataTable();
$('#btnSearch').click(function() {
oTable.search($('#txtSearch').val()).draw();
})
而且,我寧願單獨搜索Active列,那種:
oTable
.column(2).search('Yes')
.columns([0,1]).search($('#txtSearch').val())
.draw();
但這不起作用。任何幫助表示讚賞
你可以檢查我的yadcf過濾器的數據表,它有9個不同的過濾器類型與其他第三方插件集成http://yadcf-showcase.appspot.com/ https://github.com/vedmack/yadcf – Daniel 2014-08-30 18:40:24