Reputation: 199
I am trying to auto resize my NatTable. I have few things :
1) My NatTable consists of only one column. 2) I am hiding NatTable occasionally. 3) The Part Control surrounding NatTable auto resizes on mouse drag. NatTable should also fit the size. 4) I have custom cell painters for NatTable Cells.
I tried with my bodyDataLayer(Which is based on GlazedListsDataProvider) :
bodyDataLayer.setDefaultRowHeight(35);
bodyDataLayer.setColumnWidthByPosition(0, 100);
bodyDataLayer.setColumnPercentageSizing(true);
But nattable does not show up at all. If I double click the invisible rows, I get required row. But natTable itself does not appear. NatTable shows up only if bodyDataLayer.setDefaultColumnWidth(SOME_VALUE); Only default column width works.
I tried to add a Paint Listener to NatTable to initialize auto resize commands as suggested on Official Documentation. But it has no effect at all.
I tried to add
natTable.setLayerPainter(
new NatGridLayerPainter(natTable, SOME_VALUE));
with auto resizing of columns by position.But it also renders nothing. I am wondering how to resize my NatTable?
Upvotes: 1
Views: 1182
Reputation: 4231
Typically DataLayer#setColumnPercentageSizing(true)
should be sufficient for percentage sizing.
I can only assume that hiding NatTable occasionally has a negative effect, because that might lead to miscalculation of the percentage values. 100% of 0 is still 0.
Are you calling NatTable#setVisible(false)
to hide the NatTable? In that case try to execute the following lines of code
natTable.doCommand(new ClientAreaResizeCommand(natTable));
natTable.redraw();
If that fixes your issue, please open a ticket and report that issue. In that case it seems we need to add a listener for SWT.Show
or override setVisible()
to execute these lines of code on visibility changes.
Upvotes: 2