-
5 Jan 2012 7:48 AM #11
Extending ComboBoxCell and overriding onSelect is also a solution.
Selecting something in the dropdown would fire the CollapseEvent event. So depending on your application, that maybe also a solution
-
5 Jan 2012 7:57 AM #12
Thanks Sven.
A bit unexpected but it works.
Could you please help me with one additional problem:
I'm adding combobox data to the store. After it I need to make the first item selected. Currently I'm doing the following magic:
store.addAll(data.getPeriods());
periodsComboBox.clearSelections();
periodsComboBox.setValue(data.getPeriods().get(0));
periodsComboBox.setText(data.getPeriods().get(0).getName());
Is there any simpler way to preselect one of the Combobox items?
-
12 Jan 2012 8:39 AM #13
Custom ComboBoxCell appearance
Custom ComboBoxCell appearance
ComboBoxCell class is missing constructor which accepts custom appearance. Is there any workaround for this?
-
13 Mar 2012 2:51 PM #14
All solutions proposed above are hacks.
In GXT 2.2.5 ComboBox had the following functionality:- ComboBox.addSelectionChangedListener() - ability to listen for selection change events, which were fired both when user made a selection in the drop down and when ComboBox.select() or ComboBox.setSelection() methods were invoked programmatically.
- ComboBox.select() and ComboBox.setSelection() - ability to select an item programmatically, which will populate the combo box field with selected value and fire the SelectionChanged event.
Thanks in advance.
Arkady.
-
30 Mar 2012 8:59 AM #15
I agree that the proposed "solutions" are absolutely not solutions, and that those workarounds could be characterized as hacks.
The more important point here is what a standard and reasonable expectation would be of the API. It would be reasonable to expect that when a combobox selection changes, the SelectionChangedEvent would fire. That is not what is happening according to the previous posters.
The combobox selection changes when a user selects an item in the combo list. While this is similar to the CollapseEvent, it is not the same, and that is why relying on CollapseEvent would be a hack. Users have other ways of making a selection than this.
This needs to be fixed in a robust way, so that the API conforms to normal and reasonable expectations of behavior.
Thanks,
Don P.
-
3 Apr 2012 1:54 PM #16
ComboBox now fires SelectionEvent when an item in the drop down list is selected. This allows you to react to the user choosing an item from the drop down list without waiting for the user to move focus away from the combo box.
Look for this change in the Release Candidate build.
-
3 Apr 2012 2:38 PM #17
This is great, thanks.
Now the only remaining issue is to fix the select() APIs to trigger the selection programmatically.
Best regards,
Arkady.
-
3 Apr 2012 6:41 PM #18
What behaviour is it exactly that you're expecting from ComboBox.select? Specifically, under what situation do you plan to use ComboBox.select such that you're not setting a new value anyway (at which point, you should use ComboBox.setValue)?
In Ext GWT 2, ComboBox.select does not fire the SelectionEvent, so we are not unintentionally omitting the event from ComboBox.select in Ext GWT 3. In fact, you will notice this in the JavaDoc comments for each:
This is because ComboBox.select selects (highlights) one of the items in the dropdown list. It doesn't dismiss the list the way a user would when the user clicks on an item. If you would like for an expanded drop-down list to be dismissed, again consider using setValue (after calling collapse to dismiss the dropdown list).Code:* Select an item in the dropdown list by its numeric index in the list. This * function does NOT cause the select event to fire. The list must expanded * for this function to work, otherwise use #setValue.
-
9 Apr 2012 1:42 PM #19
Using gxt-3.0.0-rc.jar, the event is fired, but the ComboBox still doesn't return the correct value until focus is lost on the widget.
Is this the expected behavior?Code:cb.addSelectionHandler(new SelectionHandler<String>() { @Override public void onSelection(SelectionEvent<String> event) { cb.getSelectedIndex() //returns -1 cb.getSelectedText() //returns "" cb.getValue() //returns null } });
-
9 Apr 2012 1:52 PM #20
event.getItem() returns you the selected item.
Best regards,
Arkady.
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote