Javascript 数据表显示/隐藏列会干扰列筛选
我正在尝试使用列过滤和显示/隐藏功能设置数据表。当以有序方式选择列(如0,1,2,3,4,5)时,它似乎可以正常工作,但当以无序方式选择列(如0,1,2,3,6)时,单个列过滤器与公共搜索功能混淆。在本例中,当搜索列过滤器6时,其行为类似于公共搜索函数 在检查fire bug列filter 6中的请求时,将在sSearch而不是sSearch_6中传递值。这是我的密码:Javascript 数据表显示/隐藏列会干扰列筛选,javascript,jquery,datatables,Javascript,Jquery,Datatables,我正在尝试使用列过滤和显示/隐藏功能设置数据表。当以有序方式选择列(如0,1,2,3,4,5)时,它似乎可以正常工作,但当以无序方式选择列(如0,1,2,3,6)时,单个列过滤器与公共搜索功能混淆。在本例中,当搜索列过滤器6时,其行为类似于公共搜索函数 在检查fire bug列filter 6中的请求时,将在sSearch而不是sSearch_6中传递值。这是我的密码: $(document).ready(function () { var table= $("#data_table")
$(document).ready(function () {
var table= $("#data_table").dataTable({
"bDestroy":true,
"bStateSave": true,
"aaSorting": [[1, "asc"]],
"bProcessing": false,
"bServerSide": true,
"sAjaxSource": "/queryDb",
"bJQueryUI": true,
"bAutoWidth": false,
"bFilter":true,
"bLengthChange": true,
"bPaginate": true,
"bSort": true,
"iDisplayLength": 10,
"bInfo": true,
"sPaginationType": "full_numbers",
"fnDrawCallback" : function() {
}
}).columnFilter({
sPlaceHolder: "head:after",
aoColumns: [ { type: "text" },
{ type: "text" },
{ type: "text" },
{ type: "text" },
{ type: "text" },
{ type: "text" },
{ type: "text" },
{ type: "text" },
{ type: "text" },
{ type: "text" }
]
});
});
显示/隐藏功能:
function fnShow(iCol)
{
var oTable = $("#data_table").dataTable();
var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
oTable.fnSetColumnVis( iCol, true );
}
function fnHide(iCol2)
{
var oTable2 = $("#data_table").dataTable();
var bVis = oTable2.fnSettings().aoColumns[iCol2].bVisible;
oTable2.fnSetColumnVis( iCol2, false );
}
请帮助我解决这个错误。似乎列过滤器插件有问题。我删除了ColumnFilter插件,为每个列创建了自定义搜索输入,并使用fnFilter()将这些值附加到服务器端ajax请求中 像, 表1.fnFilter(“”); 表1.fnFilter(“val0”,0); 表1.fnFilter(“val1”,1); 等等