PDA

View Full Version : Client-side filtered Combobox



tpi
1 Feb 2012, 8:10 AM
Hi everyone,
I'm using gxt 2.1.1 in a gwt project.
I need to create a Client-side filtered Combobox that updates the values with the inputed text.

I looked at the example http://www.sencha.com/examples/#advancedcombobox but I haven't understand how it works and I don't know if it is what I need..
Can you give me a suggestion on how to realize it?

Thank you in advance,
Federica

hulseware
16 Feb 2012, 5:20 AM
If the combo box is editable, you can type in the text box. If you want to have that item entered into the pulldown list for future use via selection, you need to take the getRawValue data, create a ModelData object and add it to the store used by the combo box:


// Code for setting up the combo box
ComboBox box=new ComboBox();
box.setDisplayField("name");
box.setValueField("key");
box.setStore(new ListStore());

// Code added to validateValue method of the combo box
ListStore store=box.getStore();
String val=box.getRawValue();
ModelData md=new BaseModelData();
md.set(getDisplayField(),val);
md.set(getValueField(),val);
store.add(md);

This should always add every value typed into the text field into the pulldown list - you'd have to add more code to detect the value already in the list and not re-add it.