multi selection filter using dropdown list in header of each column

multi selection filter using dropdown list in header of each column

pratsprats Posts: 45Questions: 21Answers: 0

Hi I tried this feature:
datatables.net/release-datatables/examples/api/multi_filter_select.html

But this is for single value selection from each column. I want to implement multi value selection column filter, so when we select multi values from same column filter dropdown, will get data related to selected values from dropdown list.
My jsFiddle is:https://jsfiddle.net/prats1251/vf3c3sn4/
Thanks.

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 21,563Questions: 26Answers: 4,995
    Answer ✓

    Here are a couple of options. You can use regex. I added an example (based on this example) to your fiddle:
    https://jsfiddle.net/vf3c3sn4/1/

    </p>Global Search:<input type="text" class="global_filter" id="global_filter"></p>
    
     $(document).ready(function() {
            function filterGlobal () {
                $('#example').DataTable().search(
                    "^(?=.?(" + $('#global_filter').val() + ")).?",
                    true
                ).draw();
            }
    
        $('input.global_filter').on( 'keyup click', function () {
            filterGlobal();
        } );
    

    You can type something like this into the Global Search box: as|br|ca

    You can create a custom search plugin:
    https://datatables.net/manual/plug-ins/search

    Or you can try YADCF:
    http://yadcf-showcase.appspot.com/cumulative_filtering.html#

  • pratsprats Posts: 45Questions: 21Answers: 0

    @kthorngren I have added yadcf 0.9.1 plugin.Its good plugin but not properly working for ajax data as getting error
    Uncaught TypeError: Cannot read property 'mData' of undefined at jquery.dataTables.yadcf.min.js
    might be I have not initialised data properly with yadcf

  • kthorngrenkthorngren Posts: 21,563Questions: 26Answers: 4,995
    Answer ✓

    @prats I created a simple yadcf with select2 example using ajax data. Its using the datatables ajax example data provided by Allan.

    Maybe you can try your code with my example or post it for review.

    Kevin

  • pratsprats Posts: 45Questions: 21Answers: 0

    Thanks @kthorngren.

This discussion has been closed.