Announcement

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

    bug when drag selecting multiple records in ListGrid

    Hi

    There is a bug in ListGrid when drag selecting multiple records. Object event.getSelection() returns wrong number of selected records. It is possible to see it when you for example drag select 3 records, then event.getSelection().length equals 2. When you drag select 2 records and then select 1 without releasing mouse button, then event.getSelection().length equals 2. I attach code to easy reproduce it. Please check it.
    Thanks, Adam

    I am using SmartGWT built 2012-03-10, FF 10

    Code:
    package org.yournamehere.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.types.SelectionStyle;
    import com.smartgwt.client.widgets.Label;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.grid.ListGridRecord;
    import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
    import com.smartgwt.client.widgets.grid.events.SelectionEvent;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class MainEntryPoint implements EntryPoint {
    
        ListGrid grid = new ListGrid();
        Label label = new Label("0");
    
        public void onModuleLoad() {
    
            grid.addSelectionChangedHandler(new SelectionChangedHandler() {
    
                public void onSelectionChanged(SelectionEvent event) {
                    label.setContents(Integer.toString(event.getSelection().length));
                }
            });
            grid.setWidth(300);
            grid.setHeight(200);
            grid.setData(createRecords());
            grid.setSelectionType(SelectionStyle.MULTIPLE);
            grid.setCanDragSelect(true);
            grid.setFields(new ListGridField("a"));
    
            VLayout layout = new VLayout();
            layout.addMember(grid);
            layout.addMember(label);
            layout.draw();
        }
    
        private ListGridRecord[] createRecords() {
            ListGridRecord[] result = new ListGridRecord[10];
            for (int i = 0; i < result.length; i++) {
                result[i] = new ListGridRecord();
                result[i].setAttribute("a", "a" + i);
            }
            return result;
        }
    }

    #2
    Thanks for the heads-up. We see the issue and have made a change to resolve it in the 3.1d branch.

    However, we'd also recommend you just use "selectionUpdated" rather than "selectionChanged" here. The difference is that selection changed fires for every record that gets selected / deselected, so if you select a list of records you get multiple notifications, whereas selectionUpdated will just fire a single notification and you would use 'getSelection' to determine the selection once the process is done.

    Comment

    Working...
    X