0

我想让 NatTable 的列动态扩展到

  • 显示单元格中的整个值
  • 完全填充父复合

似乎我可以做一个或另一个,但不能两者兼而有之。换句话说,如果我有一个大的父 Composite 并且 NatTable 只有几列具有非常短的值,我将有很多空白空间(也就是 NatTable 与父 Composites 宽度相比将有一个小宽度)

我尝试了以下代码片段:

// This sets the full width of the Composite, but all columns are equal 
// width. If a column has a long value, the value will be truncated.
glazedListsGridLayer.getBodyDataLayer().setColumnPercentageSizing(true);

// This auto-resizes the columns based on their values. If the values
// are short, this table will not fill the width of the composite
nattable.addConfiguration(new DefaultNatTableStyleConfiguration() { {
  cellPainter = new LineBorderDecorator(new TextPainter(false, true, 5, true));}
});

我想我正在寻找一种混合,其中列将根据值自动调​​整大小。如果表格没有填满复合材料的宽度,我想要:

  • 所有列均匀地增加额外的宽度,直到表格与 Composite 父级或
  • 特定列将添加额外的宽度,直到表格与复合父级的大小相同

如果表格填充了 Composite 的整个宽度并且列值很长,我想确保表格有一个水平滚动条(必要时)以查看所有列及其未截断的值

有没有人知道如何实现这一目标?谢谢!

4

1 回答 1

1

当前不支持指定最小宽度。但如果它只是一个视觉的东西,你可以尝试使用NatGridLayerPainter在整个可用空间上打印的东西。这就像一个附加列,但实际上没有添加列。

NatTable natTable = new NatTable(parent);
NatGridLayerPainter layerPainter = new NatGridLayerPainter(natTable);
natTable.setLayerPainter(layerPainter);
于 2016-10-27T18:24:06.740 回答