-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello,
I have a problem while reseting or refreshing a selected item in a combobox.
Here is the Fiddle : http://zkfiddle.org/sample/h20l03/68-reset-combobox-MVVM
To reproduce : - run the fiddle - choose the element in combobox - click on reset, the combobox content should be deleted - if it works, it will always on the same run, so, close the window and run again...
Sometimes, the combobox's content is deleted, sometimes it is not, it seems random. I tried with the NotifyChange annotation, same result. I'm on google chrome 70.0.3538.77. Thanks for your help and sorry for my bad english.
I am not fully sure why your scenario behaves non deterministic, I assume it has to do with the notify change "*". When using a ListModelList there's no need to replace the model, just clear and refill it (it will update the combobox content automatically), then things get a lot simpler and the problem didn't happen anymore.
e.g.: http://zkfiddle.org/sample/h20l03/71-reset-combobox-MVVM
Besides you don't need to bind the property selectedSearchedOrg to selectedItem. The ListModelList will keep track of selections automatically for you. You can retrieve it by calling searchedOrgs.getSelection(). Keeping duplicate state can often lead to synchronization issues. Only relying on a single source makes cleanup much simpler.
see this updated example: http://zkfiddle.org/sample/h20l03/72-reset-combobox-MVVM
It takes advantage of ListModelList keeping track of the selection, and only if the selection is changed you can update your own model property, or decide to keep it. Another benefit is that you only expose getters to the UI, making it easier to reason about the data flow.
Asked: 2019-01-04 18:01:54 +0800
Seen: 22 times
Last updated: Jan 07 '19
How to capture onScroll Event of Combobox
combobox does not scroll autocompleted text into view
I want to take different value from label(value) and pass to @bind object
Combobox sometimes clears the selected item
zk combobox filtering option is not working inside listbox .
Zk create custom event for COmbo box?
Fetching Key-Value pair for ComboBox using SimpleListModel
How to set selected combobox when using setModel
ComboBox autocomplete does not work with onOk event [closed]