View Full Version : How to set or how to prepopulate the combo with default value ?
Amulya
20 May 2009, 11:04 PM
Hi All,
I have a combo with 3 values,
1.Duration
2.Volume
3. No. of events
Whenever I open the form or screen, I have to display(prepopulate) 'Duration' in the combo as default value, so that if user doesn't selects in the combo also, it will take it as 'Duration'.
Is there any method in combo to set one of the value of combo as default.
Help me to solve this problem.
Thanks in advance!
kolli
21 May 2009, 5:52 AM
1) use SimpleCombobox
2) setSimpleValue method to set the initial value.
Amulya
21 May 2009, 9:33 PM
Thanks for the suggestion :)... But I need some more clarifications, when I used SimpleCombobox, Im unable to use setStore() method, which is neccessary.
Also help me how to use the method setSimpleValue().
Help me for further move ASAP, Im pasting my code snippet....
ListStore<Attribute> attribute =new ListStore<Attribute>();
ComboBox<Attribute> attributeCombo = new ComboBox<Attribute>();
attributeCombo = new ComboBox<Attribute>();
attributeCombo.setFieldLabel("Attribute");
attributeCombo.setDisplayField("attribute");
attributeCombo.setItemId("packtype");
attributeCombo.enableEvents(true);
attributeCombo.setMinChars(1);
attributeCombo.setStore(attribute);
//attributeCombo.setSimpleValue(attribute);
attributeCombo.setView(new ListView<Attribute>() {
@Override
protected Attribute prepareData(Attribute state) {
state.set("attribute", state.getAttribute());
return state;
}
});
kolli
22 May 2009, 5:38 AM
oh as you were talking about 3 values i thought you were going to use fixed values in the combobox.
I use the store datachanged event and use the following code snippet in it.
List<ModelData> m = new ArrayList<ModelData>();
//GEt the modelData for the item you want to set as default
m.add(modelData);
combobox.setSelection(m);
Hope this helps
Amulya
26 May 2009, 10:52 PM
Thanks very much Ravikanth ... :)
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.