具有多选下拉菜单的数据表特定列过滤器

2023-12-02

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

Ref: https://datatables.net/examples/api/multi_filter_select.html

但对我来说,它不同,我需要对多选下拉菜单执行相同的操作。因此数据表应该相应地显示结果。

因此,如上面的链接所示,我无法选择两个办事处“东京和伦敦”。我已经使用多选插件实现了编码(http://harvesthq.github.io/chosen/)但数据表只采用一个选项。

那可能吗?如果是这样,请您帮忙解决这个问题。


经过长时间的搜索,我找到了解决这个问题的方法。其实很简单。以下是我对此选项的修复。

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

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(); 

更新:我们需要在“search()”中添加两个参数 功能。

        
        search(val_1,val_2,val_3)
        
        where,
        val_1 is search string with "|" symbol separated. 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)
    

Ref: https://datatables.net/reference/api/search()

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

具有多选下拉菜单的数据表特定列过滤器 的相关文章

随机推荐