-
16 May 2011 4:37 PM #1
[FNR] GXT 2.2.4 ComboBox force selection fails is ComboBox never expanded
[FNR] GXT 2.2.4 ComboBox force selection fails is ComboBox never expanded
The ComboBox setForceSelection does not force a selection if the ComboxBox is never expanded and lazy render is true (the default).
To preproduce:- Create a ComboBox with edit true and forceSelection true
- Quickly type characters in the box that will not trigger the expansion of the combo options
- Click or tab out of the box
Expected Result:
The combo should force a selection to the last selected option in the combo's list, but it does not - the invalid text is left unvalidated.
If instead you type one letter that triggers the expansion or click the trigger your self then the combo will force a selection when you tab out.
Cause and Workaround:
This issue is caused by the lazy rendering - doForce() calls getValue() which returns the value because the field "initialised" is still false - it should return null because the invalid vale is not in the store's models. The "initialised" field only gets set to true when the combo is expanded.
The workaround is to disable lazy rendering (which creates the combo list and sets "initialised" to true).
Ideally you should not have to disable lazy rendering to have force selection work correctly.
Here is the code to reproduce the issue. Note if you don't set a simple value then you get a validation error (but instead you should get a forced selection)
Code:public class ComboBoxBug implements EntryPoint { public void onModuleLoad() { FormPanel formPanel = new FormPanel(); final SimpleComboBox<String> aCombo = new SimpleComboBox<String>(); aCombo.setFieldLabel("Validate issue"); aCombo.setName("field"); aCombo.add(Arrays.asList(new String[] {"AAA", "AAB", "AAC"})); aCombo.setEditable(true); aCombo.setForceSelection(true); aCombo.setTypeAhead(true); aCombo.setAllowBlank(false); aCombo.setTriggerAction(TriggerAction.ALL); aCombo.setSimpleValue("AAA"); // GXT bug - if lazy render & not expanded list yet & type invalid text then doforce fails //aCombo.setLazyRender(false); formPanel.add(aCombo); RootPanel.get().add(formPanel); } }
-
30 Jun 2011 1:19 PM #2
-
30 Jun 2011 11:02 PM #3
As workaround you can set lazy render to true.
You could comment out the block in getValue that checks for initialzed, or you could use the workaround for now.
We could also force the list initialization in a forceselect. This would not be a huge change in behaviour, any thoughts?
-
30 Jun 2011 11:26 PM #4
Also i am not normally posting a patch to the public, i think its the best for here. If you have any time, you maybe want to test this change and report back here.Code:Index: user/src/com/extjs/gxt/ui/client/widget/form/ComboBox.java =================================================================== --- user/src/com/extjs/gxt/ui/client/widget/form/ComboBox.java (revision 2407) +++ user/src/com/extjs/gxt/ui/client/widget/form/ComboBox.java (working copy) @@ -551,6 +551,7 @@ return value; } if (store != null) { + store.clearFilters(); getPropertyEditor().setList(store.getModels()); } @@ -1001,6 +1002,10 @@ return; } + if (!initialized) { + createList(true); + } + if (getValue() == null) { if (lastSelectionText != null && !"".equals(lastSelectionText)) { setRawValue(lastSelectionText);
-
6 Jul 2011 10:39 PM #5
Sven, this fix works for me - not sure what effect the store.clearFilters() has, but I see no ill effects so far.you maybe want to test this change and report back here.
Can you sent the rev number when you commit?
Regards,
The_Jackal
-
13 Sep 2011 5:24 AM #6
Fixed in SVN as of revision 2429
Thank you for reporting this bug. We will make it our priority to review this report.
Similar Threads
-
ComboBox on(select) & on(change), 2nd selection, 4th, even count, fails
By baboen in forum Ext: DiscussionReplies: 0Last Post: 2 May 2011, 8:31 AM -
[PR4] Multi selection Combobox selection rendering away from the combobox
By slemmon in forum Ext:BugsReplies: 0Last Post: 16 Mar 2011, 12:23 PM -
[CLOSED] [2.0.3] ComboBox fails to use items after a selection has been done
By Jose Jeria in forum Ext GWT: Bugs (2.x)Replies: 4Last Post: 21 Oct 2009, 3:40 AM -
Force Combobox value if...
By fruitwerks in forum Ext 3.x: Help & DiscussionReplies: 2Last Post: 13 Sep 2009, 12:57 PM -
combobox - force selection doubts
By fother in forum Ext GWT: DiscussionReplies: 0Last Post: 23 Jul 2009, 10:03 AM


Reply With Quote