PDA

View Full Version : ComboBox, set default value



treblereel
30 Mar 2011, 5:29 AM
Hi all,
How do i can set default (or first, its ok) value in ComboxBox ?


ComboBox<BeanModel> comboBox = new ComboBox<BeanModel>();
comboBox.setDisplayField("name");
comboBox.setWidth(150);
comboBox.setName("department");
comboBox.setFieldLabel("Department");
comboBox.setAllowBlank(false);
comboBox.setEditable(false);
comboBox.setStore(departmentStore);
comboBox.setTriggerAction(TriggerAction.ALL);

blay
30 Mar 2011, 5:43 AM
To set a value:

comboBox.setValue(BeanModel)

You can override the "setStore" method, so when the store its set you set the first value:



@Override
public void setStore(ListStore<D> store){
super.setStore(store);
setValue(getStore().getModels().getAt(0));
}

or something like that

treblereel
30 Mar 2011, 5:51 AM
try:
comboBox.setValue(departmentStore.getAt(0));

treblereel
30 Mar 2011, 5:54 AM
Thanks, its work !