【问题标题】:Data table specific column filter with multi select drop down具有多选下拉菜单的数据表特定列过滤器
【发布时间】:2014-12-15 08:19:05
【问题描述】:

我在 Datatable API 中看到了这种可能性,用于使用 Drop down 进行特定列过滤。

参考:https://datatables.net/examples/api/multi_filter_select.html

但对我来说,它不同,我需要对多选下拉菜单做同样的事情。所以数据表应该相应地显示结果。

所以在上面的链接中,我不能选择两个办公室“东京和伦敦”。我已经使用多选插件(http://harvesthq.github.io/chosen/)实现了编码,但数据表只需要一个选项。

这可能吗?如果可以,请您帮忙。

【问题讨论】:

    标签: datatables jquery-datatables


    【解决方案1】:

    经过长时间的搜索,我找到了解决方案。

    其实很简单。以下是我对此选项的修复,

    已经有一个选项可以根据以下链接搜索特定的立柱虎钳,

    http://www.datatables.net/examples/api/multi_filter.html

       // DataTable
        var table = $('#example').DataTable();
    
        // 2 is column id 
        // "India" is search string
        table.column( 2 ).search( 'India' ).draw(); 
    
    So the above one will search for "India" in a specific column "2" (Say like "Country" column)
    
    Here i need an ability to search for more than one country like "India, Japan etc.,"
    
    So the code will be as follows,
    
            // DataTable
            var table = $('#example').DataTable();
    
            // 2 is column id 
            // "India|Japan|Spain" is search string
            table.column( 2 ).search( 'India|Japan|Spain', true, false ).draw(); 
    
        Updated: We need to add two more parameters in the "search()" function.
    
        search(val_1,val_2,val_3)
    
        where,
        val_1 is search string with "|" symbol seperated. So it contains regular express chars as per the example. 
        val_2 is true (To enable regular express in the search)
        val_3 is false (To disable smart search. default is true)
    

    参考:https://datatables.net/reference/api/search()

    所以我刚刚在搜索字符串之间添加了一个“管道”符号:p LOL

    【讨论】:

    • @Nishant 更新了答案。请在搜索功能中分别添加 true 和 false 作为第二个和第三个参数以启用正则表达式。
    • 我在数据表的列下方有一个下拉菜单,我想选择多个值,一旦选择了这些值,搜索应该使用这些新值。我在这里看到了您的答案,但不确定如何将选定的下拉值映射到搜索功能。你能帮我解决这个问题吗?如果您想了解有关我的问题的详细信息,请点击此处的链接。 stackoverflow.com/questions/41328602/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-29
    • 2020-11-08
    • 2019-08-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多