Thank you for reporting this bug. We will make it our priority to review this report.
-
Sencha Premium Member
ComboBox same label selection issue [all versions]
Required Information
Version(s) of Ext GWT
All Ext GWT 3.0 versions
Browser versions and OS
(and desktop environment, if applicable)
- All Desktop environments / All browsers
Virtual Machine
«No»
Description
When you create a ComboBox with a ListStore which contains two items with different ModelKeys (ModelKeyProvider) and the same Label (LabelProvider)
For instance:
Element1:
ModelKey: FOO
Label: MyLabel
Element2
ModelKey: BAR
Label: MyLabel
If you then use the ListView of the ComboBox and select the second item (both are labeled "MyLabel")
and then call the getValue() method of the ComboBox, you will lways get the first item back.
Run mode
Both
Steps to reproduce the problem
Not provided
Expected result
When I select the second Item of the two equally labeled Items, I ComboBox.getValue() should also return the second item.
Actual result
When I select the second Item of the two equally labeled Items, I ComboBox.getValue() returns the first of the two.
Test case
Not provided
Helpful Information
By looking at the ComboBox code I discovered, that issue seems to be that the ComboBox iterates thru the ListStore and returns the first item, which has the same label as the selected item.
Screenshot or video
Not provided
Live test
Not provided
Debugging already done
No
Possible fix
Not provided
-
Sencha Premium Member
Any news on this?
Is it clear or shall I provide an EntryPoint?
Best regards,
Daniel
-
How does the user tell the difference? Just by position in this list? The only way I can see this use case as making sense is if the user expected to understand the order and is not permitted to use the keyboard to enter values, since they would have no way of indicating which one to select. Additionally, they must be expected to expand the combo box to see which of the two identical values they have picked.
Do I have that right? Or is there another case where two items would have the same label, but be recognizable as having different values by an end user?
Apparently my sencha forum inbox is too small to hold my messages, please contact me at
[email protected] to reach me.
-
Sencha Premium Member
Hi Colin,
the application I am working on right now is data driven. Therefore I have little control over the labels which are returned from the backend. The model keys are unique, but the labels aren't. It's quite rare, that there are duplicate labels. But if it occures, it is impossible for the user to try out both items and decide which one is the correct item.
But I have found a workaround by adding a SelectionHandler as shown below:
Code:
comboBox.addSelectionHandler(new SelectionHandler<T>()
{
@Override
public void onSelection(SelectionEvent<T> event)
{
comboBox.setValue(event.getSelectedItem(), true);
}
});
I explicitly set the item on the ComboBox which the SelectionEvent provides since that item is correct. Later calls to getValue() will return the correct item. By firering an event on setValue() I am also improving the following workaround:
http://www.sencha.com/forum/showthre...omboBox-issues
Best regards,
Daniel
-
Sencha Premium Member
I'm facing the same problem.
The user can tell the difference because I'm using a template for the ListView of the ComboBox.
The template is defined so that it shows different fields of the models, not just the one I'm using as display field. So when the user expands the combobox they are presented with perfectly distinguishable values.
-
Sencha Premium Member
Hi,
We are in the same situation and it's a real problem in our application.
We have to manage a list of items which label can be identical. I agree in terms of user experience, it's not the best, but it's the user choice and we need to handle it.
Actually, when we select a value, the combobox select the right one and then, a blur event occurs and select the first one in the list matching the same label.
I went deeper into the implementation of the combo box and it turns out that the selection (coming from blur) is based on the label and not on the selection model by calling:com.sencha.gxt.cell.core.client.form.ComboBoxCell#selectByValue(String).
A dirty workaround is to manage internaly the selected value and subclass ComboBoxCell to return it when selectByValue is invoked but we shouldn't have to do this.
Is it possible to fix this issue?
Best regards,
Julien