Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid SelectionChangedHandler bug

    I slightly changed the Simple Select Sample in this way...

    Code:
           public class SimpleSelectSample implements EntryPoint {  
    Canvas canvas = new Canvas();
    
            final ListGrid selectedCountriesGrid = new ListGrid();
            selectedCountriesGrid.setWidth(250);
            selectedCountriesGrid.setHeight(100);
            selectedCountriesGrid.setTop(250);
            selectedCountriesGrid.setShowAllRecords(true);
            ListGridField selectedCountriesField = new ListGridField("countryName", "Selected Countries");
            selectedCountriesGrid.setFields(selectedCountriesField);
    
            final ListGrid countryGrid = new ListGrid();
            countryGrid.setWidth(500);
            countryGrid.setHeight(224);
            countryGrid.setShowAllRecords(true);
            countryGrid.setSelectionType(SelectionStyle.SIMPLE);
    
            ListGridField countryCodeField = new ListGridField("countryCode", "Flag", 40);
            countryCodeField.setAlign(Alignment.CENTER);
            countryCodeField.setType(ListGridFieldType.IMAGE);
            countryCodeField.setImageURLPrefix("flags/16/");
            countryCodeField.setImageURLSuffix(".png");
    
            ListGridField nameField = new ListGridField("countryName", "Country");
    ---------------------------------------------------------
            nameField.setFrozen(true);
    ---------------------------------------------------------
            ListGridField capitalField = new ListGridField("capital", "Capital");
            ListGridField continentField = new ListGridField("continent", "Continent");
            countryGrid.setFields(countryCodeField, nameField, capitalField, continentField);
    
            countryGrid.setData(CountrySampleData.getRecords());
            countryGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
                public void onSelectionChanged(SelectionEvent event) {
                    selectedCountriesGrid.setData(countryGrid.getSelection());
                }
            });
    
            canvas.addChild(countryGrid);
            canvas.addChild(selectedCountriesGrid);
    
            canvas.draw();
        }
    And now, when I select a row for the first time, the SelectionChanged event handler is called twice
    If I select another row, the SelectionChanged is called four times.

    SmartClient Version v12.1p_2022-11-02/Pro Deployment (2022-11-02)
    Last edited by Hirn; 21 Apr 2023, 06:07.

    #2
    The same thing happens if you add such code to the Timeline example...

    Code:
    ListGridField titleField = new ListGridField("title");
    
            ListGrid tasksLineProps = new ListGrid();
            tasksLineProps.setCanSort(false);
            tasksLineProps.setSelectionType(SelectionStyle.SINGLE);
            tasksLineProps.setShowSelectedStyle(true);
            tasksLineProps.setFields(titleField);
    
            tasksLineProps.addSelectionChangedHandler(new SelectionChangedHandler() {
                @Override
                public void onSelectionChanged(SelectionEvent event) {
    ----
    ----
                }
            });
    
    Timeline calendar = new Timeline();
    calendar.setAutoChildProperties("timelineView", tasksLineProps);
    ---
    ---

    Comment


      #3
      Thanks for the notification and the additional information.
      We've made a change to the framework to address this problem. Please try the next nightly build, dated May 19 2023 or above

      Regards
      Isomorphic Software

      Comment


        #4
        What about version 13? I observe similar behavior on 13.0-p20230506 and 13.0-p20230704 also. SelectionChangedHandler is called twice when clicking all the time on the same record. Once state = false and the next state = true. It's as if the record is first deselected and then selected.
        I checked version 12.1-p20230627 and this does not happen there.

        Comment


          #5
          Rather than selectionChanged, it sounds like you might be looking for selectionUpdated, which is doc'd as firing only once for a selection modification.

          Comment


            #6
            I know about selectionUpdated. But I click on the same record all the time, not a different one. And then selectionChanged is triggered, too. Previous versions didn't behave that way. I am observing this on 13.

            Comment


              #7
              So the question is, from 13 selectionChanged is called every time? Even if we click on the same record, so we don't really change anything. This did not happen in previous versions.
              We have existing code that started to work differently after the switch to 13. So the question is, is this an intentional change?

              Comment


                #8
                No it's not an intentional change. The underlying SmartClient javascript framework doesn't exhibit this behavior, but we do see the issue in SmartGWT.

                We'll investigate and let you know here when it's been fixed.

                Comment


                  #9
                  Hi, any updates? Is this not a simple issue?

                  Comment


                    #10
                    This issue has been addressed in 13.0 and 13.1 for today's builds, dated July 22, and later ones.

                    Comment


                      #11
                      Thank you, checked latest 13.0 and it works.

                      Comment

                      Working...
                      X