DataTables中的多列过滤器(bootstrap)

时间:2022-02-12 14:27:31

I am using the DataTables API for my table in the application. I have a scenario where I want multiple columns be enabled for filtering purpose.

我在应用程序中为我的表使用DataTables API。我有一个场景,我希望启用多个列进行过滤。

I have this code setup now. But it only searches for Column2. Even if I enter value for Column1 it doesn't search.

我现在有这个代码设置。但它只搜索Column2。即使我输入Column1的值,它也不会搜索。

    $('#btnFilter').click(function () {
        table.fnFilter($('#Column1').val());
        table.fnFilter($('#Column2').val());
    });

1 个解决方案

#1


i guess fnFilter will also accepts iColumn paramter

我猜fnFilter也会接受iColumn参数

so try using like this

所以尝试使用这样的

table.fnFilter($('#Column1').val(), 0);  //0 is the first column
table.fnFilter($('#Column2').val(), 1);

#1


i guess fnFilter will also accepts iColumn paramter

我猜fnFilter也会接受iColumn参数

so try using like this

所以尝试使用这样的

table.fnFilter($('#Column1').val(), 0);  //0 is the first column
table.fnFilter($('#Column2').val(), 1);