Using an Observable List with Select Form
See original GitHub issueI might be using Select form the wrong way, but I have an internal API that returns an observable list which I would like to use in a select box. I’m not sure how to make the select options update with the new elements added to the observable list. This is what I have so far:
class SomeContainer: SimplePanel() {
var someList: ObservableList<Pair<String, String>> = observableListOf()
init {
val formPanel = formPanel<SomeForm> {
add(
SomeForm::select,
Select(
label = "Simple select"
).also {
options = someList
liveSearch = true
}
)
}
someList.add(Pair("someValue", "someLabel"))
someList.add(Pair("someOtherValue", "someOtherLabel"))
.....
}
}
The result is an empty options list when selecting, perhaps this is expected since options expects a non-mutable list. Is there any way to do this?
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
ObservableList (JavaFX 8) - Oracle Help Center
Creates a SortedList wrapper of this list using the specified comparator. Methods inherited from interface java.util.List · add, add, addAll, addAll, clear, ...
Read more >How to properly implement observable list to populate a ...
In my project, a table view is being populated with information based on what value is currently selected in the combo box. And...
Read more >Inputs.select - Observable
A Select allows the user to choose from a given set of values. A Select is recommended over a Radio or a Checkbox...
Read more >JavaFX Tutorial - Observable List example with Combo Box
JavaFX tutorial on observablelist. We go over examples with binding to a ComboBox. Multiple techniques are covered such as binding in the ...
Read more >JavaFX Tutorial 13 - ComboBox, ObservableList (Remastered)
The ComboBox is also known as choice list or dropdown list that contains a list of items from which the user can choose....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
And remeber to add the
Select
component to theFormPanel
after theDataContainer
is created. It’s important, because it must be a child of some visual container (one “connected” to the root component).The
options
parameter of theSelect
component is designed for static usage. To have dynamic list of options use theDataContainer
as a non-visual wrapper, like that: