0

Combobox question? please help me?

asked 2010-01-28 01:53:29 +0800

bayaraa2054 gravatar image bayaraa2054
75 2

updated 2010-01-28 01:54:27 +0800

My combobox shows only 10 result. How to I show all result with scroll.
My code like this:
private void drawCombo(){
private List<Comboitem> items = new ArrayList<Comboitem>();
// this List have a more data.
Combobox combobox = new Combobox();
ListModel locaListModel = new SimpleListModel(items);
combobox.setModel(locaListModel);
combobox.setItemRenderer(new ComboItemRenderer());
row.appendChild(combobox);
}
// Inner class
public class ComboItemRenderer implements ComboitemRenderer {

@Override
public void render(Comboitem item, Object value) throws Exception {
item.setLabel(((Comboitem)value).getLabel());
item.setValue(((Comboitem)value).getValue());
}

}

// I just configure
combobox.setAutocomplete(true); //doesn't work
Are there any other way?
http://www.zkoss.org/zkdemo/userguide/#f5 - in this section combobox working fine with more data

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2010-01-28 20:12:36 +0800

PeterKuo gravatar image PeterKuo
481 2

You can look into the api
http://www.zkoss.org/javadoc/3.5.2/zul/org/zkoss/zul/Combobox.html

setRows() to bigger value is what you need.

link publish delete flag offensive edit

answered 2010-01-28 21:35:24 +0800

bayaraa2054 gravatar image bayaraa2054
75 2

Yes, i just tried. but this doesn't work. I get that message "Combobox doesn't support multiple rows, 12". I configured setRows(12).

link publish delete flag offensive edit

answered 2010-01-28 23:16:21 +0800

ruknow gravatar image ruknow
168 1 3

use custom LitModel implements ListSubModel

link publish delete flag offensive edit

answered 2010-02-02 02:05:49 +0800

bayaraa2054 gravatar image bayaraa2054
75 2

updated 2010-02-02 02:11:22 +0800

Hello, Thanks.

I have some confusion. How to implement ListSubModel. how use getSubModel(Object value, int nRows); What is this parameter (value).
Are there any complete source? http://www.zkoss.org/smalltalks/comboboxEnhancement this is not sufficient.
My source code follows:

//Class
public class CodingBlockUIHandler extends GenericForwardComposer implements ListSubModel{
}

// Inside Bind method
Combobox combobox = new Combobox();
ListModel locaListModel = getSubModel(combobox, -1)
combobox.setModel(locaListModel);

// My sub method
public ListModel getSubModel(Object value, int nRows) {
//final String idx = value == null ? "" : objectToString(value);
if (nRows < 0) {
nRows = 10;
}
final LinkedList data = new LinkedList();
for (int i = 0; i < getTempSIList().size(); i++) {
data.add(getTempSIList().get(i));
}
return new SimpleListModel(data);
}

This is shows only 10 results again.

Thank you.

link publish delete flag offensive edit

answered 2010-02-02 20:16:15 +0800

PeterKuo gravatar image PeterKuo
481 2

updated 2010-02-02 20:22:28 +0800

After trace the code, you'll know why, and how to modify it.

You can download the zk5 source code first.
Search SimpleListModel.java,
look into getSubModel(Object value, int nRows)
And then grep getSubModel,
you'll see how Combobox.java call such method.

So, you have to implement your own model.

BTW, a good title can attract other's help. Your title didn't tell much.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-01-28 01:53:29 +0800

Seen: 1,420 times

Last updated: Feb 02 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More