Announcement

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

    ListGrid with boolean fields: timing issues

    SmartGWT LGPL version 2.4 + 2.5(2011-06-21)
    Browsers: Issue occurs with Firefox 4.0.1, Chromium 14.0 while is works with IE8

    Summary: Having a ListGrid with several boolean fields (checkboxes) per record, the checkbox selection is forgotten/reset to 'null' if the mouse clicking happens too fast.


    The sample below shows the behaviour: Add a new record and select all checkboxes one- after the other, as fast as you can: The visual representation still shows all checkboxes selected, but internally some have been reset to 'null'. How many and which ones depends on your click speed.
    Doing the same selection process slowly and then adding a new record leaves all of them enabled.
    Adding a record is not changing any data in this test case, it is just a mean to show the internal data representation of the previous record to show the problem.

    Can this behaviour be workarounded by any setting on the list grid or list grid field?
    By the way: This is not a nonsense case, this is a real-world-case that in fact happens to many of our customers.

    Code:
    import com.smartgwt.client.types.ListGridEditEvent;
    import com.smartgwt.client.types.ListGridFieldType;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Label;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.grid.ListGridRecord;
    
    public class TestClass {
        
        public void onModuleLoad() {
            Canvas canvas = new Canvas();  
            
            final ListGrid grid = new ListGrid();  
            grid.setWidth(350);  
            grid.setHeight(224);  
            grid.setShowAllRecords(true);  
            grid.setCanEdit(true);  
            grid.setEditEvent(ListGridEditEvent.CLICK);  
            grid.setModalEditing(true);   
            
            int fieldCount = 6;
            ListGridField [] fields = new ListGridField[fieldCount];
            for (int n = 0; n < fieldCount; n++) {
                ListGridField field = new ListGridField("b" + n, "B" + n);
                field.setType(ListGridFieldType.BOOLEAN);
                fields[n] = field;
            }                
            grid.setFields(fields);
                             
            IButton add = new IButton("Add new record");  
            add.addClickHandler(new ClickHandler() {  
                @Override
                public void onClick(ClickEvent event) {  
                    ListGridRecord rec = new ListGridRecord();  
                    grid.addData(rec);                 
                }
            });  
            add.setLeft(0);  
            add.setTop(240);  
            add.setWidth(140);
            
            Label label1 = new Label("Add a new record, select all checkboxes as fast as you can. All checkboxes seem to be selected. " +
                    "Then, anytime after this, add another record. Some checkboxes of the previous record which had been selected " +
                    "before will be unselected right now. The number of de-selected checkboxes depends on your click/selection speed. ");
            Label label2 = new Label("If you instead select the checkboxes of a new record slowly and after that " +
                    "add another record, all previous checkboxes will be enabled."); 
            Label label3 = new Label("This obviously is a timing issue. " + 
                    "Selecting the next checkbox while the previous one is not yet stored seems to reset/overwrite that value while" +
                    " the visual representation shows the expected value.");
            label1.setTop(280);  
            label1.setWidth(400);        
            label2.setTop(340);  
            label2.setWidth(400);
            label3.setTop(380);  
            label3.setWidth(400);
            
            canvas.addChild(grid);
            canvas.addChild(add);  
            canvas.addChild(label1);
            canvas.addChild(label2);
            canvas.addChild(label3);
            canvas.draw();  
        }
        
    }

    #2
    We're having trouble reproducing this issue with the sample you provided.
    What platform are you seeing this on? Are you able to reproduce in multiple environments?

    Without having reproduced it, it seems like the bug may be due to an interaction between ListGridField canToggle behavior and single click editing.

    Does your grid contain only boolean fields? If so setting editEvent to NONE may provide a temporary workaround (The boolean fields will default to canToggle true, so will still be editable by users with a single click, but the grid will never truly go into "edit mode").

    However we'd obviously like to get to the bottom of this bug so if you can think of any information that might help us to reproduce it that would be useful.

    Comment


      #3
      I rechecked it with the following browsers/environments:

      o Firefox 3.6.18 (Win XP)
      o Firefox 4.0 (Windows 7)
      o Firefox 3.6.17 (openSUSE 11.3)
      o Firefox 4.0.1 (openSUSE 11.4)


      The above described problem always happens when you manage to select all items in the row within 3 seconds. If it takes longer, it does not occur. This is anytime reproducible in all environments that I tested.

      As in my case the real grid (not the above test case) contains non-boolean fields, setting editEvent to NONE would not solve the problem.

      Comment

      Working...
      X