Skip to content

MultiSelectDropdown : How to pre-select objects on load depending on DataTable column? #218

Answered by s-cork
EsbenLorenzen asked this question in Q&A
Discussion options

You must be logged in to vote

The source of truth for the selected property is the component's state since it changes as the user interacts with it.

When you set the selected property it sets options from the dropdown to selected.
A user might interact with the dropdown which would change the value of that property.
i.e. the selected property doesn't remember its state from code.
It always checks the components state, which is the source of truth here.

In your code snippet you set the selected property but the component has no options yet.

TL;DR

  • switch the last two lines.
  • The dropdown has no items and so setting the selected property doesn't make sense.

It's possible that we could do something fancy where we treat …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by s-cork
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #204 on November 25, 2021 12:17.