PDA

View Full Version : [FIXED] [2.2.5] ComboBox resets filtered list after one second when force selection set



The_Jackal
13 Oct 2011, 5:28 PM
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.


store.clearFilters();

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.

Can we just remove that line? Having a force selection ComboBox on a form is a very common feature.

Here is the ComboBox code:


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);


let me know if you need any more info

Regards,
Carl Pritchett

sven
13 Oct 2011, 10:46 PM
getValue should probably restore filters after obtaining the value. We will take a look

The_Jackal
14 Oct 2011, 6:30 PM
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).

minusForty
20 Oct 2011, 11:16 AM
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.

The_Jackal
20 Oct 2011, 4:19 PM
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.

minusForty
21 Oct 2011, 7:35 AM
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.



@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;

}

minusForty
21 Oct 2011, 11:12 AM
A minor correction for this workaround, you need to surround the for loop and the line after it with the following check:


if( filters != null ){

The_Jackal
21 Oct 2011, 7:27 PM
Try this - it should be faster as there is no filter manipulation:


@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();
}

minusForty
24 Oct 2011, 7:39 AM
Unfortunately, the problem with doing that is the final call to
return super.getValue() 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.

The_Jackal
25 Oct 2011, 10:15 PM
Here is the gist of the super method from the Field class. You can blend it into your method:


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;
}
}

minusForty
26 Oct 2011, 8:18 AM
Ah, we're possibly talking about extending different classes. I am extending the ComboBox class, so super would call the getValue() method of the ComboBox class, not the Field class. And since the problem lies within the ComboBox class, I can't get around it.

The_Jackal
28 Oct 2011, 5:53 PM
No, I'm talking about extending ComboBox and then replace the call to super with the code I'd showed you (which is from ComboxBox's parent class Field).

minusForty
31 Oct 2011, 8:00 AM
Ah, understood, thanks. That seemed to work great. The only thing I had to comment out (because it was a private member variable) was the following:


if (!initialized) {
return value;
}

The_Jackal
31 Oct 2011, 8:47 PM
Hopefully we will see this fix in the future, but my guess is it will be a while till 2.2.6 comes...

The_Jackal
10 Oct 2012, 3:47 PM
Hi Darrell / Sven,

Could you add this patch to the source for 2.2.6/7 as we are still using this version and it's awkward to always have to rebuild from source. I raised this some time ago and it will tide us over till we move to GXT3



Index: ComboBox.java
===================================================================
--- ComboBox.java (revision 2488)
+++ ComboBox.java (working copy)
@@ -551,7 +551,7 @@
return value;
}
if (store != null) {
- store.clearFilters();
+ // store.clearFilters(); // GXT Bug Filtered suggestions reset on form validate when forceSelection = true
getPropertyEditor().setList(store.getModels());
}


Thanks.

eburgerwa
10 Oct 2012, 6:41 PM
Yes, in the same boat here - would be great if this patch could be applied.

Thanks
Eugene

The_Jackal
21 Apr 2013, 6:20 PM
Sencha team, I saw a recent post that said a 2.3 release is due soon, so would you consider fixing this bug? You just need to comment out one line (554) in ComboBox.java.

We have been running patched code for 6 months now so I believe it's a safe fix.

Carl.

The_Jackal
5 May 2013, 3:39 PM
To anyone following this issue - this fix was not includes with the 2.3 release.

The_Jackal
11 Jun 2013, 6:54 AM
Maybe for 2.3.1??

branflake2267
25 Jul 2013, 1:20 PM
Thanks for the report! I have opened a bug in our bug tracker.

branflake2267
21 Aug 2013, 2:27 PM
This issue has been fixed. It will be out in the next release of 2.3.1. It is also available from the support channel svn source.