-
|
Hi, author. Thank you for your response to this issue ! As I described in my question, I found that the FreezeColumn command works fine in code without grouped headers, but it doesn't take effect in tables with grouped headers. Additionally, when there are grouped columns, the Freeze PopMenu in the ColumnHeader also fails to work. I trigger freeze command by two ways:
Is my NatTable configuration correct? If there are issues, how should I modify or try to fix it? I am using NatTable version 2.1.0, and I have also tested it on version 2.5.0 with the same result. Here is the core code for my ColumnHeaderLayer and NatTable configuration: private ILayer buildColumnHeaderLayer() {
ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, getBodyLayer(), selectionLayer);
SortHeaderLayer sortHeaderLayer = new SortHeaderLayer<>(columnHeaderLayer, sortModel);
ColumnGroupHeaderLayer columnGroupHeaderLayer = new ColumnGroupHeaderLayer(
sortHeaderLayer, selectionLayer, columnGroupModel);
columnGroupHeaderLayer.setRowHeight(DEFAULT_ROWHEIGHT);
if (filterStrategy == null) {
return columnGroupHeaderLayer;
}
FilterRowHeaderComposite<String> filterRowHeaderComposite = new FilterRowHeaderComposite<>(
filterStrategy,
columnGroupHeaderLayer, columnHeaderDataProvider, filterStrategy.getConfigRegistry());
filterRowHeaderComposite.getFilterRowDataLayer().setDefaultRowHeight(DEFAULT_ROWHEIGHT);
return filterRowHeaderComposite;
}
private NatTable createNatTable(Composite container, BaseGridLayer gridLayer, ConfigRegistry configRegistry) {
NatTable natTable = new NatTable(container, gridLayer, false);
natTable.setConfigRegistry(configRegistry);
natTable.setLayerPainter(new NatGridLayerPainter(natTable, rowHeight));
natTable.setBackground(GUIHelper.COLOR_WHITE);
natTable.addConfiguration(new BaseStyleConfiguration());
natTable.addConfiguration(new BaseFilterConfiguration());
natTable.addConfiguration(new CurConfiguration());
natTable.addConfiguration(
new BaseMenuConfiguration(
new CurMenuAction(dataProvider, gridLayer.getSelectionLayer())));
natTable.addConfiguration(new CustomHeaderMenuConfiguration(natTable, new CustomHeaderMenuAction(this, dataProvider)));
natTable.addConfiguration(new SingleClickSortConfiguration());
BaseSelectionTipLabel selectionTipLabel = new BaseSelectionTipLabel(parent, dataProvider);
natTable.addLayerListener(new LayerSectionListener(this, toolBar, selectionTipLabel, this));
natTable.configure();
dataProvider.update();
natTable.doCommand(new AutoResizeAllColumnsCommand(natTable));
natTable.doCommand(new FreezeColumnCommand(gridLayer.getSelectionLayer(), 1));
return natTable;
}
private PopupMenuBuilder createColumnHeaderMenu(NatTable natTable) {
ILayer layer = natTable.getLayer();
PopupMenuBuilder popupMenuBuilder = createMenuBuilder(natTable)
.withHideColumnMenuItem()
.withShowAllColumnsMenuItem()
.withAutoResizeSelectedColumnsMenuItem()
.withClearAllFilters()
.withFreezeColumnMenuItem()
.withUnfreezeMenuItem("Unfreeze column");
return popupMenuBuilder;
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
As already answered in the issue, please have a look at one of our examples, dependent on which column grouping implementation you are using:
You are not sharing your body layer composition. So I can't tell anything else here. |
Beta Was this translation helpful? Give feedback.
-
|
And IIRC you are using the natTable.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
natTable.doCommand(new FreezeColumnCommand(gridLayer.getBodyLayer(), 1));
natTable.removePaintListener(this);
}
}); |
Beta Was this translation helpful? Give feedback.

And IIRC you are using the
FreezeColumnCommandwith an incorrect position. You are using theSelectionLayeras reference for the position. But the command is handled in theCompositeFreezeLayer. So it might fail because of the position transformation.Additionally if you want to programmatically freeze a column on startup, you need to do this using a
PaintListener. Before the initial paint the width of the freeze layers in theCompositeFreezeLayerare 0 and therefore the command is not processed. For initial programmatic freeze, use a snippet like this: