Results 1 to 3 of 3

Thread: GXT SimpleComboBox: mismatch between selected item and index

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Jul 2011

    Default GXT SimpleComboBox: mismatch between selected item and index


    I have a problem with GXT SimpleComboBox which I'm not sure is a bug or a (unexpected) feature. I have the example code below, which should work out of the box if you put it inside onModuleLoad() of your GWT entry point.

    I add 10 items to the combo box and whenever I select one of them I get a matching item and item index in the statements. However, when one of the items is selected and the combo box loses focus because I temporarily switch to another window (using the Mac version of Alt-Tab) the combo box expands with a single item (the currently selected one). This is illustrated in the following figure


    When I go back to the browser window (where the combo box is displayed), the combo box remains selected and expanded with a single item (as in the figure). If I press Enter the prints the correct item (Item 5) but not the correct item index (0). It seems that the combo box ListStore suddenly contains only a single item instead of 10.

    I do not understand this behavior. If anyone has some ideas about this I would be very glad to hear about it.



        final SimpleComboBox<String> comboBox 
           = new SimpleComboBox<String>(new LabelProvider<String>()
          public String getLabel(String s)
            return s;
        comboBox.setEmptyText("Select item...");
        for(int i = 0; i < 10; ++i)
          comboBox.getStore().add("Item " + i);
        comboBox.addSelectionHandler(new SelectionHandler<String>()
          public void onSelection(SelectionEvent<String> event)
            String item = event.getSelectedItem();
  "selectedItem: " + item);
  "selectedIndex: " + comboBox.getStore().indexOf(item));

  2. #2
    Sencha User
    Join Date
    Feb 2009


    From the image, it appears that the store is filtered down to the item being typed in, yet I see setTriggerAction(ALL) in your code - this seems inconsistent.

    If the store is being filtered, the ListStore will only report indexOf on visible items. This is ideal for most of the use cases involving the store, since data widgets like the Grid, ListView, or ComboBox should only care about the visible set of items. Similarly, store.get(i) will return a matching item from the indexOf value.

    If the store is *not* being filtered, the index shouldn't be zero (as you noted), but the screenshot shouldn't show just one item.

    It could be worth adding an event handler on StoreFilterEvents that that come from the store, and look at the stack trace to see what is causing that filter to occur even though you have setTriggerAction(ALL). The only filter being added within ComboBox is inside the ComboBox cell, and that is when the query is performed - with triggerAction=ALL, clicking on the trigger (ComboBoxCell.onTriggerClick) should show all items.

    There is a delayed query that also invokes doQuery, run on each key up, to try to match the keys the user has entered - this only should happen with each keystroke, with a minimal delay. But since you've described the list shrinking only on focus from another window, I'm not entirely sure this is the cause.

  3. #3


    I'm also facing the same problem, did you get any workaround?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts