Multi-select within the Individual Column Searching function

Multi-select within the Individual Column Searching function

Lonnie.HullLonnie.Hull Posts: 32Questions: 11Answers: 0

Hello,

I'm still new to Javascript, but I'm trying to learn.

I'm using the Individual Column Searching function found here
https://www.datatables.net/examples/api/multi_filter_select.html

I'm wondering if it's possible to incorporate this type of functionality into dataTables with this function

https://codepen.io/rustybailey/pen/GJjvYB

I would work with this code, but the list of options is not dynamic. It's embedded into the JS. I want to be able to choose two or more criteria and show those after filtering. i.e. Director and Developer, or any other combination.

I created a test environment, but haven't done anything as I have no idea if it's even possible.

http://live.datatables.net/tohehohe/1953/edit

Thanks for any help you can give me.

Replies

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    Hi @Lonnie.Hull ,

    @kthorngren 's example here from this thread may help.

    Cheers,

    Colin

  • Lonnie.HullLonnie.Hull Posts: 32Questions: 11Answers: 0

    @Colin,

    Thank you so much for that example. I thought I had scoured everywhere for an example, but apparently not.

    I was able to get it working, thanks again.

    http://live.datatables.net/yewebawo/1/

    Just a quick question, if you have time. I had to comment out some of the JS files to get this to work. Is there any way to know exactly which JS files I should be using other than trial and error?

  • kthorngrenkthorngren Posts: 20,302Questions: 26Answers: 4,769

    Basically you need to add the select2 JS and CSS files to your project.

        <!-- Select2 plugin -->
        <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css">
        <!-- Select2 plugin -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
    

    Kevin

  • Lonnie.HullLonnie.Hull Posts: 32Questions: 11Answers: 0

    @kthorngren ,

    I worked that out eventually. At times I'm combining functions that other people, that are much better at this than I, created. When I do, there are sometimes 4 or 5 JS files and 2 to 3 CSS files. The CSS files I can add certain criteria to or even merge, if need be. But if I have the JS files included, or even in the incorrect order, it breaks the function.
    I'm just trying to get more knowledge in how the best way to know what order to put them in, or if having both is redundant.

    Thanks for your help.

  • kthorngrenkthorngren Posts: 20,302Questions: 26Answers: 4,769

    You definitely don't want to duplicate the files. For Datatables you can use the Downlaod Builder to get the appropriate files for the libraries/extension you want to use. They will be in order.

    In general you need to understand the dependancies, like Datatables relies on jQuery so jQuery should be loaded first, etc.

    HTH,

    Kevin

  • alelaualelau Posts: 12Questions: 2Answers: 0

    Hi,

    I know this is an older thread but I am quit new to Datatables and javascript. I want to know in the example pointed out by @colin here. Is the $.map function a Datatables or JQuery function, and what does it do?

    Thanks,

    Alex

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    Hi @alelau ,

    It's a jQuery method,

    Cheers,

    Colin

  • alelaualelau Posts: 12Questions: 2Answers: 0

    @colin
    Thanks for the quick reply.

  • Wheels496Wheels496 Posts: 1Questions: 0Answers: 0

    Hello

    Are there any alternatives for multiple select filter? I managed to implement the "select2" multiple select library. However, the table I am displaying has around 65,000 rows and therefore the page takes around 4 minutes to load.

    Thanks

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    I think at 65k records, it's going to take a while to build. You could try something like this perhaps: https://jsfiddle.net/jvretamero/bv6g0r64/

    Colin

This discussion has been closed.