Nebula NatTable如何显示行号

How can to show the row number in Nebula NatTable

我可以使用这些代码向 NatTable 显示 CSV 内容:

IDataProvider bodyDataProvider = ...;

DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
SelectionLayer selectionLayer = new SelectionLayer(bodyDataLayer);
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
viewportLayer.setRegionName(GridRegion.BODY);

natTable.setLayer(viewportLayer);

如何显示行号?我尝试使用 GridLayer 但没有列 header。请帮忙!

我解决了这个问题。我用了 CompositeLayer:

IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
DataLayer rowHeaderDataLayer = new DataLayer(rowHeaderDataProvider);
ILayer rowHeaderLayer = new RowHeaderLayer(
                    rowHeaderDataLayer,
                    viewportLayer,
                    selectionLayer);
CompositeLayer compositeLayer = new CompositeLayer(2, 1);
compositeLayer.setChildLayer(GridRegion.ROW_HEADER, rowHeaderLayer, 0, 0);
compositeLayer.setChildLayer(GridRegion.BODY, viewportLayer, 1, 0);
natTable.setLayer(compositeLayer);