Hi,
We have a grid that renders content with varying heights, as record components. It seems that the record components are positioned all over the place and we are having trouble fixing the issue.
The issue is reproducible with the following code:
Click "refresh" button at the bottom to randomize some content to the grid. The problem seems to lie in the fact that as the grid rendered as a record component is wrapping it's content and it has a varying height (overflow visible), the framework has trouble rendering the components in the correct position. The problem is always "fixed" if you resize your browser a bit to force a redraw.
Is this a bug, is there something wrong with the code or is there a workaround?
Using SmartClient Version: v13.0p_2022-01-30/LGPL Development Only (built 2022-01-30), latest Chrome browser on OS X.
We have a grid that renders content with varying heights, as record components. It seems that the record components are positioned all over the place and we are having trouble fixing the issue.
The issue is reproducible with the following code:
Code:
private DataSource ds; private ListGrid grid; public void doOnModuleLoad() { viewport = new VLayout(); viewport.setWidth100(); viewport.setHeight100(); ds = new DataSource(); DataSourceTextField pk = new DataSourceTextField("id"); pk.setPrimaryKey(true); DataSourceIntegerField sub = new DataSourceIntegerField("sub"); ds.setFields(pk, sub); ds.setClientOnly(true); grid = new ListGrid() { @Override protected Canvas createRecordComponent(ListGridRecord r, Integer col) { if(col == 1) { int sub = r.getAttributeAsInt("sub"); if(sub > 0) { // return a sub listgrid with randomized nr of rows in it ListGrid g = new ListGrid(); g.setHeight(1); g.setOverflow(Overflow.VISIBLE); g.setBodyOverflow(Overflow.VISIBLE); g.setFixedRecordHeights(false); g.setWrapCells(true); DataSource sds = new DataSource(); DataSourceTextField f1 = new DataSourceTextField("f1"); f1.setPrimaryKey(true); DataSourceTextField f2 = new DataSourceTextField("f2"); sds.setFields(f1, f2); sds.setClientOnly(true); g.setDataSource(sds); Record[] sd = new Record[sub]; for(int i=0; i<sub; i++) { ListGridRecord s = new ListGridRecord(); s.setAttribute("f1", "pk" + i); // randomize some wrapping text s.setAttribute("f2", "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it.".substring(0, Random.nextInt(215))); sd[i] = s; } g.setData(sd); return g; } } return null; } }; grid.setWidth100(); grid.setHeight100(); grid.setFixedRecordHeights(false); grid.setDataSource(ds); grid.setAutoFetchData(false); grid.setShowRecordComponents(true); grid.setShowRecordComponentsByCell(true); grid.setRecordComponentPosition(EmbeddedPosition.WITHIN); grid.setRecordComponentPoolingMode(RecordComponentPoolingMode.DATA); ListGridField pkField = new ListGridField("id"); pkField.setWidth(80); ListGridField subField = new ListGridField("sub"); grid.setFields(pkField, subField); viewport.addMember(grid); Button b = new Button("refresh"); b.addClickHandler(clickEvent -> { refresh(); }); viewport.addMember(b); viewport.draw(); } public void refresh() { ds.setTestData(new Record[] { gr(1), gr(2), gr(3), gr(4), gr(5), gr(6), gr(7), gr(8) }); ds.fetchData(null, (response, rawData, request) -> { final ResultSet resultSet = new ResultSet(); resultSet.setDataSource(ds); Record[] data = response.getData(); resultSet.setAllRows(data); grid.setData(resultSet); }); } public ListGridRecord gr(int i) { ListGridRecord r = new ListGridRecord(); r.setAttribute("id", "primarykey" + i); r.setAttribute("sub", Math.abs(Random.nextInt(4))); return r; }
Is this a bug, is there something wrong with the code or is there a workaround?
Using SmartClient Version: v13.0p_2022-01-30/LGPL Development Only (built 2022-01-30), latest Chrome browser on OS X.
Comment