View Full Version : XComboBox and CheckBoxListView

14 Mar 2011, 11:25 AM

I´ve been searching threads about this issue and I´ve found some posts where it´s said that he issue about not being able to make selections from XcomboBox (via setSelection) is due to CheckBoxListView. I´m using GXT 2.2.1 and it still doesn´t work. Any help?


14 Mar 2011, 4:26 PM
After trying for a while I´ve found a workaround for this issue. Not elegant at all, but it works (at least in my tests ;) ). Probably I´m doing something wrong but here is my temporal solution:

We add a method in "XComboBox", in order to being able to execute a protected method of ComboBox.

public void triggerBlur() {

We create a method where the values are set:

public void doIt(){
DeferredCommand.addCommand(new Command()

public void execute()

The deferred command is necessary because of triggerBlur (which its invoked to lose the focus on the grid). The 'trick' is expand the combo, so now, it´s rendered and the CheckBoxListView sets right the values.

15 Mar 2011, 1:37 AM
Just another tip I´ve realized:

As implemented, ModelData passed to setSelection must be in the store of the comboBox. So in a case like you get values for your comboBox, and then you wanna set some of those values because an object has them (for example, a form where you wanna modify an existing object), it´s necessary to find the model in the store (because to set it true it HAS to be the same object).
A method for doing that would be:

public void setSelection(List<D> selection, String key) {

ListStore<D> tempStore = getStore();
for (D d : selection) {

((CheckBoxListView<D>) getView()).setChecked(
tempStore.findModel(key, d.get(key)), true);