-
10 Jul 2009 5:58 AM #1
How to manually select an item (combobox)
How to manually select an item (combobox)
I have a combobox bound to a store. This store is bound to a GWT-RPC service (via proxy) and works well.
What I need to do is once the data (list of BeanModelTag) returns from the server, manually set the combobox's selected item to the first bean in the list.
I've tried combobox.setValue as well combobox.select inside the loaderLoad event, but not working.
Is this event the right place I should put any setValue or select? If not, where?
-
10 Jul 2009 6:32 AM #2
Create your combo box and overwrite the method get and set
the behaviour of the combo box should be different.. but the gxt team.. dont change.. so its the soluction..Code:MyComboBox extends ComboBox
other way.. you can use memory proxy.. but its bad.. will store all data of your combobox..
-
10 Jul 2009 6:36 AM #3
-
10 Jul 2009 6:44 AM #4
so.. try add a listener in a store when the data finished store and call the method select..
-
10 Jul 2009 7:54 AM #5
Adding a listener to the store solved the problem. =)
Thank you!!!Code:storeContrato = new ListStore<BeanModel>(loaderContrato); storeContrato.addStoreListener(new StoreListener<BeanModel>() { @Override @SuppressWarnings("unchecked") public void storeDataChanged(StoreEvent<BeanModel> se) { super.storeDataChanged(se); List<BeanModel> beans = (List<BeanModel>) se.getStore().getModels(); if (beans != null && beans.size() == 1) { comboContrato.setValue(beans.get(0)); } } });
-
5 Jan 2011 9:46 PM #6
I have a combo box in GXT wizard. Which has a proxy service & loader to retrieve the elements. How can i load the elements manually instead of loading by automatic ?
-
25 Jan 2012 12:13 PM #7
-
25 Jan 2012 12:38 PM #8
-
25 Jan 2012 2:47 PM #9
Sven thanks for the fast reply, but still i cant make it work.
My code is the follow: ( I have been used Reghin's code)
When I click the combobox this fire the listener. But no one item is selected. Can you point me in right direction?Code:final ComboBox combobox; combobox = (ComboBox) this.itemModificacion.getItemByItemId(f.getName()); combobox.getStore().addStoreListener(new StoreListener<BeanModel>() { @Override @SuppressWarnings("unchecked") public void storeDataChanged(StoreEvent<BeanModel> se) { super.storeDataChanged(se); List<BeanModel> beans = (List<BeanModel>) se.getStore().getModels(); if (beans != null && beans.size() == 1) { combobox.setValue(beans.get(0)); } } });
Thanks in advance
-
26 Jan 2012 9:11 AM #10
I already solve it, I changed my code as follow.
Thanks!
Code:Long fk = grid.getSelectionModel().getSelectedItem().get(f.getName()); combobox = (ComboBox) this.itemModificacion.getItemByItemId(f.getName()); List<BeanModel> beans = (List<BeanModel>) combobox.getStore().getModels(); if (beans != null) { int i = 0; Long auxfk; do { auxfk = (Long)beans.get(i).getProperties().get("id"); combobox.setValue(beans.get(i)); i++; } while (auxfk != fk); }



Reply With Quote