-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi All,
I want my Combobox to be Autosuggest box, where I am fetching all products. Now to make Combobox autosuggest I a understand the only option is to load it using setModel function.
But the problem I am facing here is if I set String array like below, I can't get the product id of it.
(ListModel lml=new SimpleListModel(Dictionary.getDirectory()))
I have taken reference from w3.zkoss.org/zkdemo/combobox/autocomplete
Please help me solve the issue.
Here is the fiddle that has the example, currently I am setting all values in combobox, which I want to be Key-Value pairs. zkfiddle.org/sample/3ifu29k/6-Another-new-ZK-fiddle
Hi Hrv,
Before talking about the combobox itself, I would highly recommend reading about the MVC / MVVM patterns in the ZK documentation. Implementing UI logic directly in an extended component might seem OK at first, but it will turn in a nightmare to extend / maintain very quickly.
Using SimpleListModel is possible, but keep in mind that it is immutable once created. For many purposes, you may want to look at more convenient ListModel implementations such as ListModelList, ListModelArray, ListModelMap I also recommend reading the combobox autocomplete section of the documentation here
This said, here is an example of how you could do what you described: http://zkfiddle.org/sample/6gn1kh/1-Autocomplete-in-combobox-with-beans
PS: you can should be able to add links to your posts now ;)
Hi Sir, I did something similar, used an overridden ComboItem (instead of MyEntityBean) So that I am getting all the components. But thanks for the help.
But one thing here is I need to set the selected value to the ComboBox, I know model.addToSelection(E) but here I am using older version of ZK (~3.6.3).
Can you help me set the value back in this older version please?
Asked: 2017-05-01 12:49:01 +0800
Seen: 47 times
Last updated: May 08 '17
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?
How to set selected combobox when using setModel
ComboBox autocomplete does not work with onOk event [closed]