PDA

View Full Version : Set default Values to the SimpleComboBox



rohanforu
19 May 2009, 1:29 PM
HI

I have a list i am assigned to the SimpleComboBox. I want to make one of the value in that list as the Default value.
List<String> list =new ArrayList<String>();
list.add("first");
list.add("second");
list.add("Third");
------
SimpleComboBox<String> combo=new SimpleComboBox<String>();

I want to make one of these value as default but it is not allowing me to that.

How can i do that?

Thanks
Rohan.

micgala
20 May 2009, 1:46 AM
Hi.

Have you tried this:


combo.setRawValue("second");

lkrylov
22 May 2009, 4:43 AM
SimpleComboBox<String> c = new SimpleComboBox<String>();
c.add("one");
c.add("two");
c.add("three");
c.setSimpleValue("one");

rohanforu
22 May 2009, 8:33 AM
I tried both ways ...it is not working
Is there any other way to set default values
:-/:-/:-/:-/:-/:-/

-Rohan

ram.ghadiyaram@gmail.com
5 Jun 2009, 4:51 AM
I have the same problem. Can anybody from support team help us?

daddieke
12 Jun 2009, 7:23 AM
I'm not in support team ;-)

This is weird, setSimpleValue works fine for me. Are you sure there is no other problem ? Do your values (the choices) appear in the box ? Are you setting a value that exists in the list ?

ram.ghadiyaram@gmail.com
14 Jun 2009, 10:54 PM
This works fine for me cmbType.setSimpleValue("All");
Here I want to set the default value as "All"

daddieke
15 Jun 2009, 3:25 AM
Isn't that what you do ? If you programmatically set the value to "All", that's the default value for the box. Up to the user to accept the value or change it into another.

If you want all your comboboxes to have a default value "All" without calling setSimpleValue for every box, you could subclass SimpleComboBox and set the value in the contructor. In that case don't forget to populate the store in time.

ram.ghadiyaram@gmail.com
15 Jun 2009, 3:39 AM
Yes. Using constructor way is good idea.

rohanforu
30 Jun 2009, 2:41 PM
In my scenario i have to set different values to each Combobox.
So I cannot use constructor to set default values.
I have generalized method it creates SimpleComboBox's and set it properties.
I will have Simplecombobox reference, based on the situation i will set default values to it.
Now i can set default values to it???

ram.ghadiyaram@gmail.com
1 Jul 2009, 3:44 AM
yes having constructor is a way without that also, cmbType.setSimpleValue("whatever"); should work

rohanforu
1 Jul 2009, 8:23 AM
I am using like this...
SimpleComboBox<String> value=getTheRef();
value.setSimpleValue("My Company");
///the name which i gave is already there in the dropdown list
but it is not set this value to the combobox

I am using GXT's FormBinding, i tried to assign same value to Object but that also not working.

?????????????