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.
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.
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;
}
}
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;
}
}
Comment