Data table column filter with multiple dropdown lists

I saw this possibility in the Datatable API for specific filtering of columns with Drop down.

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

But for me, its different, I need to do the same with multi-select unpacking. Thus, the data should show results accordingly.

Since in the above link I cannot select the two offices "Tokyo and London". I have implemented the coding with a multi-select plugin ( http://harvesthq.github.io/chosen/ ), but only one parameter is used in the datatable.

Is it possible? If so, can you help with this.

+3


source to share


1 answer


After searching for a long time I found a solution for this solution

In fact, everything was very simple. Below is my fix for this option,

It is already possible to search for specific column ticks according to the link below,

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)

      

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

So, I just added a pipe character between the search strings: p LOL

+5


source







All Articles