-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I am rendering data into combobox as below.
public void fillComboBox(Combobox combobox, List<valuelabel> list) {
combobox.setModel(new SimpleListModel(list) {
protected boolean inSubModel(Object key, Object value) {
String idx = key.toString();
ValueLabel myItem = (ValueLabel)value;
return idx.length() > 0 && myItem.getLabel().startsWith(idx);
}
});
combobox.setItemRenderer(new ComboitemRenderer () {
public void render(Comboitem item, Object data, int count) throws Exception {
ValueLabel valueLabel = (ValueLabel)data;
item.setLabel(valueLabel.getLabel());
item.setValue(valueLabel.getValue());
}
});
}
How to set a value(comboitem) as selected true ? Please suggest me how to do this ?
Hello.
Since you rendering items data to your combobox dynamical you will have to decide wich is the coboitem that have to be defaulted selected so in order to do that i think i may have to put a if
in you code and into you if
you mas do: item.parent.selectedItem = item
. Look at my code bellow:
<combobox >
<comboitem label="Teste"></comboitem>
<comboitem label="Joao" onCreate="self.parent.selectedItem = self"></comboitem>
</combobox>
Its very simple but its what you want.
In case that you know the index of the comboitem you want to be selected by default or that have the conditions to be setted to selected = true
you can do it directly at the combobox by doing this: onCreate = "self.selectedIndex = indexThatYouPretendToBeSelected"
Hope it helps
Asked: 2013-06-18 16:57:12 +0800
Seen: 34 times
Last updated: Jun 19 '13
Problem binding values to a composite component
How to access static member field of a class in zul without zscript
How can i load a constant in .zul
MVVM Validator: class not found ? [closed]
MVVM tab box - delay @load until tab pane displayed?
mvvm, load or save with after or before for seach command
how to fire an event when a variable value loaded through VM
is there any event trigger from zk component on binding ?
ZK team plans to dispose of Composer EventQueues no longer in scope? [closed]