Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext User
    Join Date
    Sep 2008
    Posts
    7
    Vote Rating
    0
    johnstok is on a distinguished road

      0  

    Default [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:
    1. Create an instance of ListField with multiple values in the store.
    2. Call setSelection() selecting multiple values.
    3. 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:

    Code:
    199    super.setValue(selection.get(0));
    Later the Field class' initValue() method calls the ListField class' setValue() method and this overwrites the multiple selection:

    Code:
    209    listView.getSelectionModel().select(value, false);

    Fix:
    This problem occurs because the ListField class incorrectly subclasses the Field class:

    Code:
    63    ListField<D extends ModelData> extends Field<D>
    If the class was instead defined as:

    Code:
    63    ListField<D extends ModelData> extends Field<List<D>>
    then line 199 above could be corrected to:

    Code:
    199    super.setValue(selection);

  2. #2
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    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.

  3. #3
    Ext User
    Join Date
    Sep 2008
    Posts
    7
    Vote Rating
    0
    johnstok is on a distinguished road

      0  

    Default


    You can work around this issue by subclassing the ListField class and removing the broken line:

    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();
            }
          }
    Note that you cannot use the setValue/getValue methods with this approach but they are broken on ListField anyway.

  4. #4
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Note that you cannot use the setValue/getValue methods with this approach but they are broken on ListField anyway.
    Yes but it cannot be fixed without braking the code. That is why i can only target GXT3

  5. #5
    Ext User
    Join Date
    Sep 2008
    Posts
    7
    Vote Rating
    0
    johnstok is on a distinguished road

      0  

    Default


    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

Similar Threads

  1. Replies: 1
    Last Post: 24 Nov 2009, 2:24 AM
  2. Replies: 1
    Last Post: 6 Sep 2009, 6:45 AM
  3. Replies: 1
    Last Post: 20 May 2009, 4:10 AM

Thread Participants: 1

Tags for this Thread