-
13 Oct 2011 5:28 PM #1
[2.2.5] ComboBox resets filtered list after one second when force selection set
[2.2.5] ComboBox resets filtered list after one second when force selection set
I have a ComboBox on a (validating) form that uses force selection. I type a character and the correct values are listed in the suggestion listview below the ComboBox, but only for one second as then they are replaced by the original unfiltered list. This obviously renders the list unusable.
This is caused by one of the changes in rev 2429: Line 554 in the getValue() method.
When forceSelection is true the isValid() method is called on a timer and this eventually calls getValue() and the line above clears the store (and this the users filtered list). So a second after you got a correct filtered list of suggestions, they are removed and replaced by an unfiltered list.Code:store.clearFilters();
Can we just remove that line? Having a force selection ComboBox on a form is a very common feature.
Here is the ComboBox code:
let me know if you need any more infoCode:List<String> vals = Arrays.asList(new String[] {"a", "aa", "aa1", "aa2", "b", "bb", "bb1", "bb2" }); SimpleComboBox<String> aCombo = new SimpleComboBox<String>(); aCombo.add(vals); aCombo.setEditable(true); aCombo.setForceSelection(true); aCombo.setAllowBlank(false); aCombo.setTriggerAction(TriggerAction.ALL); aCombo.setLazyRender(false); FormPanel aForm = new FormPanel(); FormBinding formBinding = new FormBinding(aForm); formBinding.addFieldBinding(new SimpleComboBoxFieldBinding(aCombo, "bindingProperty")); aForm.add(aCombo);
Regards,
Carl Pritchett
-
13 Oct 2011 10:46 PM #2
getValue should probably restore filters after obtaining the value. We will take a look
-
14 Oct 2011 6:30 PM #3
Maybe you could add a form bound combo box with force selection true to the example app. Clients often want to be able to type to select an option form a long list (like currency or country).
-
20 Oct 2011 11:16 AM #4
I know this bug was only reported a week ago, but we are about to release an app that uses GXT 2.2.5 and just noticed this issue. Does anyone know of a workaround until this is fixed? I tried setting forceSelection to false, but the bug still happens.
-
20 Oct 2011 4:19 PM #5
Suggestions:
- Get the ComboBox source code and comment out line 554 (store.clearFilters()). Recompile (via included ant file) and you're good.
- Setting forceSelection to false should work (but it won't force a selection obviously) - you may want to call setLazyRender(false) as well (it works for me)
- Override CombBox getValue() method, but them you may need to override SimpleComboBox, SimpleComboBoxValue and friends (if you use them for Combos - I do and this is how I first fixed this issue) as they are all package access.
- Try turning off form validation - not sure how to do this - you could override the checkPanel() method from FormButtonBinding to not call isValid() or override the FormPanel.isValid() method to ignore Fields that are instances of ComboBoxes (better).
The first option is the best if you can and have access to the source. If you have a support contract you can push this fix through...
Regards,
Carl.
-
21 Oct 2011 7:35 AM #6
Thank you for your suggestions Carl. We do not (yet) have a support contract, so we don't have access to the source. I tried your suggestion with disabling forceSelection and enabling lazyRender, but this did not work.
I used your 3rd suggestion, overriding the getValue method for ComboBox. This worked with a few hickups. It is a little slow when trying to select something from the combobox, but is definitely a workaround. Below is my code. I retrieve the store filters knowing that they will be cleared when calling super.getValue(), and then I re-add them and apply the filter again.
Code:@Override public YourObject getValue() {List<StoreFilter<YourObject>> filters = store.getFilters(); YourObject yourObject = super.getValue(); for (StoreFilter<YourObject> storeFilter : filters) {store.addFilter(storeFilter);} store.applyFilters(null); return yourObject;}
-
21 Oct 2011 11:12 AM #7
A minor correction for this workaround, you need to surround the for loop and the line after it with the following check:
Code:if( filters != null ){
-
21 Oct 2011 7:27 PM #8
Try this - it should be faster as there is no filter manipulation:
Code:@Override public D getValue() { if (!initialized) { return value; } if (store != null) { //store.clearFilters(); // This is the line that causes the problem getPropertyEditor().setList(store.getModels()); } doForce(); return super.getValue(); }
-
24 Oct 2011 7:39 AM #9
Unfortunately, the problem with doing that is the final call to
will call ComboBox.getValue() which will clear the filters. I suppose I am making the assumption that we are talking about extending the ComboBox class.Code:return super.getValue()
-
25 Oct 2011 10:15 PM #10
Here is the gist of the super method from the Field class. You can blend it into your method:
Code:public D getValue() { if (!rendered) { return value; } String v = getRawValue(); if (getEmptyText() != null && v.equals(getEmptyText())) { return null; } if (v == null || v.equals("")) { return null; } try { return getPropertyEditor().convertStringValue(v); } catch (Exception e) { return null; } }
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote