Announcement

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

    Bugs when deleting ListGrid records while setCanExpandRecords is true

    SmartClient Version: v12.0p_2019-05-14/LGPL Development Only (built 2019-05-14)
    Chrome 75.0.3770.80 (Official Build) (64-bit) Ubuntu Linux

    I found two bugs related to removing ListGrid records with setCanExpandRecords(true) and getExpansionComponent overridden.

    Bug #1:

    When the last two ExpansionComponents in a grid are expanded, and you delete the second-to-last record, the ExpansionComponent on the last record become "stuck", and cannot be collapsed.

    Steps to recreate:
    1) Expand rows 2 and 3.
    2) Delete the second-to-last record.
    3) Observe that clicking the arrow icon changes the icon graphic but the component is always shown.

    Code:
    import com.smartgwt.client.util.JSON;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.Window;
    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.layout.VLayout;
    
    public class GridExpDelTestWindow extends Window
    {
        private class NestedTestGrid extends ListGrid
        {
            NestedTestGrid()
            {
                setHeight(100);
                setWidth100();
                final ListGridField id = new ListGridField("id");
                final ListGridField value = new ListGridField("value");
                setFields(id, value);
            }
        }
    
        private class TestGrid extends ListGrid
        {
            TestGrid()
            {
                setWidth100();
                setHeight(300);
                setCanRemoveRecords(true);
                setCanExpandRecords(true);
    
                final ListGridField id = new ListGridField("id");
                final ListGridField value = new ListGridField("value");
                setFields(id, value);
            }
    
            @Override
            protected Canvas getExpansionComponent(final ListGridRecord record)
            {
                final NestedTestGrid rv = new NestedTestGrid();
                rv.setData(record.getAttributeAsRecordArray("nestedData"));
                return rv;
            }
        }
    
        GridExpDelTestWindow()
        {
            setAutoSize(true);
            final VLayout layout = new VLayout()
            {{
                setWidth(500);
                setHeight(500);
                setMargin(30);
                setBackgroundColor("#99CCFF");
    
                final TestGrid grid = new TestGrid();
                setMembers(grid);
    
                grid.setData(createTestData());
            }};
    
            addItem(layout);
        }
    
        private static ListGridRecord[] createTestData()
        {
            return new ListGridRecord[] { createRecord("1", "One", "Exp #1"),
                    createRecord("2", "Two", "Exp #2"),
                    createRecord("3", "Three", "Exp #3") };
        }
    
        private static ListGridRecord createRecord(String id, String value, String expansionData)
        {
            final ListGridRecord rv = new ListGridRecord();
            rv.setAttribute("id", id);
            rv.setAttribute("value", value);
            rv.setAttribute("expansionData", expansionData);
            rv.setAttribute("nestedData", JSON.decode("[{id:1,value:'" + value + " test1'},{id:2,value:'" + value + " " +
                    "test2" +
                    "'}]"));
            return rv;
        }
    }
    Bug #2:

    Similar, but only occurs when grouping in the grid.

    Steps to recreate:
    1) Delete the last row. The component must be collapsed on this row to trigger the bug.
    2) Expand one of the remaining records.
    3) Observe a blank space where the component should be, but no component.
    3a) If you collapse and expand the the group, it will redraw the missing components.

    Code:
    import com.smartgwt.client.util.JSON;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.Window;
    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.layout.VLayout;
    
    public class GridExpDelTestWindow2 extends Window
    {
        private class NestedTestGrid extends ListGrid
        {
            NestedTestGrid()
            {
                setHeight(100);
                setWidth100();
                final ListGridField id = new ListGridField("id");
                final ListGridField value = new ListGridField("value");
                setFields(id, value);
            }
        }
    
        private class TestGrid extends ListGrid
        {
            TestGrid()
            {
                setWidth100();
                setHeight(300);
                setCanExpandRecords(true);
                setCanRemoveRecords(true);
                setGroupByField("grp");
    
                final ListGridField grp = new ListGridField("grp");
                final ListGridField id = new ListGridField("id");
                final ListGridField value = new ListGridField("value");
                setFields(grp, id, value);
            }
    
            @Override
            protected Canvas getExpansionComponent(final ListGridRecord record)
            {
                final NestedTestGrid rv = new NestedTestGrid();
                rv.setData(record.getAttributeAsRecordArray("nestedData"));
                return rv;
            }
        }
    
        GridExpDelTestWindow2()
        {
            setAutoSize(true);
            final VLayout layout = new VLayout()
            {{
                setWidth(500);
                setHeight(500);
                setMargin(30);
                setBackgroundColor("#99CCFF");
    
                final TestGrid grid = new TestGrid();
                setMembers(grid);
    
                grid.setData(createTestData());
            }};
    
            addItem(layout);
        }
    
        private static ListGridRecord[] createTestData()
        {
            return new ListGridRecord[] { createRecord("grp1", "1", "One"),
                    createRecord("grp1", "2", "Two"),
                    createRecord("grp1", "3", "Three") };
        }
    
        private static ListGridRecord createRecord(String grp, String id, String value)
        {
            final ListGridRecord rv = new ListGridRecord();
            rv.setAttribute("grp", grp);
            rv.setAttribute("id", id);
            rv.setAttribute("value", value);
            rv.setAttribute("nestedData", JSON.decode("[{id:1,value:'" + value +
                    " test1'},{id:2,value:'" + value + " test2'}]"));
            return rv;
        }
    }

    #2
    We see the first issue, and that's been fixed for builds dated June 27 and later.

    We're not seeing your second issue against the latest 12.0 - please retest both issues with tomorrow's build and let us know if you still see a problem.

    Comment


      #3
      I confirmed the July 3 build of 12.0p resolved the first issue.

      The second issue with grouping+expansion components is still occuring on SmartClient Version: v12.0p_2019-07-03/LGPL Development Only (built 2019-07-03).

      Here a video demoing the example code above.

      Comment


        #4
        Ah, we see the problem now - you hadn't mentioned which skin you were using, but this issue is skin-specific - we see it trying your sample with the Enterprise series skins, but not in the more recent Flat series.

        We'll update here when it's been fixed.

        Comment


          #5
          This has now been fixed - the animated remove-record process was leaving behind some settings that interfered with later animations - please retest with a build dated July 16 and later.

          Comment

          Working...
          X