You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.
Multi-pre-select from template is either impossible or not documented.
In order to do multiple preselect "reinventing bycicle" through writing custom item populating code is required.
This is an example of how hard and hacky it gets without the feature (Dart):
//...userList was loaded from server via REST
//clear listbox items
PolymerDom listboxDom = Polymer.dom(userMultiChoice);
for (Node childNode in listboxDom.childNodes)
listboxDom.removeChild(childNode);
//recreate listbox items
List<int> selectedItems = new List<int>();
for (int i = 0; i < userList.length; i++) {
User user = userList[i];
for (String username in selectedUsernames) {//~~~~
if (username == user.username) {
selectedItems.add(i);
break;
}
}
PaperItem item = new PaperItem();
item.text = user.username;
listboxDom.append(item);
}
//apply selection
for (int item in selectedItems) {
userMultiChoice.select(item);
}
You need to set the attribute on multi listbox like this <paper-listbox multi selected-values="[1, 2]">. This is described in the list of paper-listboxproperties.
Description
Multi-pre-select from template is either impossible or not documented.
In order to do multiple preselect "reinventing bycicle" through writing custom item populating code is required.
Expected outcome
Should be able to do something like
Actual outcome
The only documented way which doesn't support multiple select (or if it does, that part is not documented at all)
Live Demo
https://elements.polymer-project.org/elements/paper-listbox?view=demo:demo/index.html&active=paper-listbox
Steps to reproduce
https://elements.polymer-project.org/elements/paper-listbox?view=demo:demo/index.html&active=paper-listbox
The text was updated successfully, but these errors were encountered: