Comma "," as MultiSelect delimeter when submitting form (Solved)

Comma "," as MultiSelect delimeter when submitting form (Solved)

musinikmusinik Posts: 22Questions: 5Answers: 1
edited January 2016 in Free community support

Hi everyone!

I can't find information anywhere, regarding the following:
When using multiselect, and you select more than 1 option, the value submited to server is joined with comma and sent as one value. The wouldn't be a problem if the delimeter would be more exotic than just comma.

I use Bootstrap Selectpicker as multiselect, and I searched through it's codes and didn't find any evidences of joining values.
Didn't find it in DataTables JS codes also.

Does anyone know where can this delimeter be changed?

The data is sent like this:

...&multiselect1=value1,value4,value6

I want to change it e.g. to:

...&multiselect1=value1$$value4$$value6

because the values themselves might have commas. And moreover these commas are not escaped anyhow by default.

Answers

  • musinikmusinik Posts: 22Questions: 5Answers: 1

    Found the closest to this topic function
    $.fn.dataTable.ext.search.push what is studing right now.

  • musinikmusinik Posts: 22Questions: 5Answers: 1
    edited January 2016

    The solution was simplier than ever! :)))
    There's an 'onchange' event which pushes the value into search() function.
    So, just join the array with required delimeter before passing it to the search().

    .on( 'change', function () {
        var val = $(this).val();
        if($.isArray(val)){val=val.join('$$');}
        column.search( val ? val : '', false, false ).draw();
    } );
    
This discussion has been closed.