MDB multiple select default value


Topic: MDB multiple select default value

O1ivier pro premium priority asked 6 years ago

Hi,

I encounter an issue while trying to determine default value for my multiple mdb-select and while the values are numbers.The multiple mdb-select works fine when it's string values.

This is my select :

<select id="product" name="product[]" class="mdb-select md-form initialized" multiple="" searchable="Search">
    <option value="">None</option>
    <optgroup label="Products Cat 1">
        <option value="22">Product 1</option>
        <option value="23">Product 2</option>
        <option value="24">Product 3</option>
        <option value="25">Product 4</option>
    </optgroup>
    <optgroup label="Products Cat 2">
        <option value="1">Product 5</option>
        <option value="2">Product 6</option>
        <option value="3" selected>Product 7</option>
        <option value="4">Product 8</option>
    </optgroup>
</select>

Of course, I initialized the select :

$('.mdb-select').material_select();

My problem is : the mdb select displayed don't have the product with value "3" checked (Product 7 in my case), it has the product with value "22" checked instead (Product 1)...

I tried to destroy et initialize again the select but it did nothing.I also tried to display the value of my select in console and I have this result :["", "22", "3"] instead of ["3"].

I don't want the "22" value, I never checked it ! The value "3" isn't checked in my select neither...

Thank you.

EDIT : Snippet if needed : https://mdbootstrap.com/snippets/jquery/o1ivier/433268


Piotr Glejzer staff commented 6 years ago

Yea, I see the problem. Sorry about that bug. I added a task for that to check/repair it as soon as possible.


O1ivier pro premium priority commented 6 years ago

Hello,

Do you know approximately when will this problem be solved ?

Thanks


Piotr Glejzer staff commented 6 years ago

I'm already looking into this. I will try to fix this a soon as possible but It will be probably fixed in the next release.


jiri.lorenz@panflex.cz pro premium priority answered 6 years ago

Please is this problem solved. Now I have the same issue.

Many thanks for answer.


Piotr Glejzer staff commented 6 years ago

which version do you use?


jiri.lorenz@panflex.cz pro premium priority commented 6 years ago

Sorry. MDB Pro 4.8.2


Piotr Glejzer staff commented 6 years ago

Ok, we will check it. Thanks for the report.


jzraibi pro premium priority commented 5 years ago

i am not able to SET multiple values for multiple select (mdb-select)


Sebastian Kaczmarek staff pro premium commented 5 years ago

@jzraibi what exactly does not work? Take a look at my snippet, it seems to work well: https://mdbootstrap.com/snippets/jquery/s-kaczmarek/1427106


gianlucagiacometti pro premium priority answered 5 years ago

@jzraibi you need to do something like:

$("#mymultipleselect").val(['val1','val2','val3']).trigger('change');

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB jQuery
  • MDB Version: 4.5.12
  • Device: Desktop
  • Browser: Google Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: Yes