-
2 Jun 2010 6:37 AM #1
[CLOSED] ListField Multi select bug - GXT 2.1.3
[CLOSED] ListField Multi select bug - GXT 2.1.3
There is a bug in the ListField class for GXT 2.1.3 version.
Steps to reproduce:- Create an instance of ListField with multiple values in the store.
- Call setSelection() selecting multiple values.
- Add the field to a FormPanel and render.
Incorrect behaviour:
Only one item will be selected.
Cause:
This bug occurs because of a faulty implementation of the setSelection() method on the ListField class. During rendering the superclass' 'value' field is set to the first element of the selection:
Later the Field class' initValue() method calls the ListField class' setValue() method and this overwrites the multiple selection:Code:199 super.setValue(selection.get(0));
Code:209 listView.getSelectionModel().select(value, false);
Fix:
This problem occurs because the ListField class incorrectly subclasses the Field class:
If the class was instead defined as:Code:63 ListField<D extends ModelData> extends Field<D>
then line 199 above could be corrected to:Code:63 ListField<D extends ModelData> extends Field<List<D>>
Code:199 super.setValue(selection);
-
2 Jun 2010 6:39 AM #2
That cannot be fixed becaue it would brake existing code. I already have all the wrong inheritence stuff on the list for GXT3
Select the items after rendering.
-
2 Jun 2010 6:45 AM #3
You can work around this issue by subclassing the ListField class and removing the broken line:
Note that you cannot use the setValue/getValue methods with this approach but they are broken on ListField anyway.Code:/** {@inheritDoc} */ @Override // Workaround a GXT multi-select bug. public void setSelection(final List<BaseModelData> selection) { if (selection != null && selection.size() > 0) { // super.setValue(selection.get(0)); listView.getSelectionModel().setSelection(selection); } else { super.setValue(null); listView.getSelectionModel().deselectAll(); } }
-
2 Jun 2010 6:47 AM #4
Yes but it cannot be fixed without braking the code. That is why i can only target GXT3Note that you cannot use the setValue/getValue methods with this approach but they are broken on ListField anyway.
-
2 Jun 2010 6:56 AM #5
Fair enough.
I added the workaround for the benefit of other users with the same problem. Another solution which doesn't require a subclass is described in this thread: http://www.extjs.com/forum/showthrea...eld-After-Load
Thank you for reporting this bug. We will make it our priority to review this report.
Similar Threads
-
[CLOSED][3.??] Ajax Form Submit is not encoding single/multi-select values
By ysolomonrr in forum Ext 3.x: BugsReplies: 1Last Post: 24 Nov 2009, 2:24 AM -
[OPEN] [CLOSED][3.0.0] serializeForm fails to urlencode values from multi-select fields
By ghendricks in forum Ext 3.x: BugsReplies: 1Last Post: 6 Sep 2009, 6:45 AM -
[CLOSED] [1.2.4] CheckBoxSelectionModel with EditorGrid - cannot select multi
By fother in forum Ext GWT: Bugs (1.x)Replies: 1Last Post: 20 May 2009, 4:10 AM


Reply With Quote