Topic: Unable to setValue for Group Select
JTH priority asked 1 year ago
I have a MDB group select input, which I'm trying to input values programmatically, however, I'm unable to accomplish this. Please note that I used the snippet of code found below on another single select dropdown, and it works just fine. However, the issue seems to be with GROUP selects.
Expected behavior Set value programmatically for GROUP select option, NOT for multi select.
Actual behavior No change in the dropdown when I run the function.
Resources (screenshots, code snippets etc.)
let includeSelect = mdb.Select.getOrCreateInstance(
document.querySelector("#include_dropdown")
);
includeSelect.setValue(["1", "9"]);
console.log(includeSelect);
OTHER EXAMPLE FOR WITH GOOD OUTCOME:
const domainSelectInstance = mdb.Select.getInstance(
document.querySelector("#domainLimit")
);
// Get the Domain_Limit value from the server response
const domainLimit = data.Domain_Limit;
// Set the value using the setValue() method
domainSelectInstance.setValue(domainLimit);
Kamila Pieńkowska staff answered 1 year ago
You can check in the documentation that this option works correctly. https://mdbootstrap.com/docs/standard/forms/select/#subsection-multi-selection
Please ensure that domainList
contains values before you use setValue
method and that domainList
is an array with values you have in your select.
JTH priority commented 1 year ago
This has to do with multi-select
I'm talking about GROUP Select.
Also, domainList was just an example that is working. It's the example above that the one for #include_dropdown that doesn't work.
Mateusz Lazaru staff commented 1 year ago
Could you create a snippet showing this problem? I've tried to reproduce the problem, but it seems to be ok.
Is it possible that domainLimit
has some type of invalid value?
https://mdbootstrap.com/snippets/standard/mlazaru/5158052#js-tab-view
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 6.2.0
- Device: PC
- Browser: Chrome
- OS: Windows
- Provided sample code: No
- Provided link: No