How to pass filter multi-select options to server

How to pass filter multi-select options to server

ziv@kpmbro.comziv@kpmbro.com Posts: 73Questions: 28Answers: 4

Hi
I got a multi select dropdown filter , and it working fine for only one selection once i select more than one it doesn't do anything.
here is my code:

var table = $('#table').DataTable({

  "initComplete": function(settings, json) {
    $('#multiselect_filter').multiselect({
      enableClickableOptGroups: true,
      enableCollapsibleOptGroups: true,
      enableFiltering: true,
      includeSelectAllOption: true
    });
    $("#multiselect_filter").on('keyup change', function() {
      table
        .columns(key)
        .search(this.value)
        .draw();
    });
  }
});

how can i resend the filter ajax value each selection ?
Thanks

Answers

  • allanallan Posts: 63,803Questions: 1Answers: 10,515 Site admin

    Hi,

    I'm not entirely sure what this.value will be when you have multiple items selected. There is a good chance it will be an array, but you'd really need to find that out before this can be fully solved (a simple console.log( this.value ) will tell you).

    columns().search() expects a simple string to be passed in. If an array is passed in it will reject it (possibly with an error - I'm not sure - it isn't valid input so I've not tested it!). Assuming you want it to be an AND filter you could just convert it to be a space separated string. If you want it to be an OR filter you would need to use a regular expression.

    Regards,
    Allan

This discussion has been closed.