如何在nattable中按列标题层分组实现文本换行

问题描述

我想在标题标题中实现文本换行。我还在顶部列标题层添加了逐层分组 文本换行在以下配置中无法按标题区域分组工作。如何在这种情况下实现文本换行

// Column header layer
this.colGrpModel = new ColumnGroupModel();

this.colHeaderLayr =
    new ColumnHeaderLayer(this.colHeaderDataLayr,this.bodyLayr,this.bodyLayr.getSelectionLayer());

this.colGrpHeaderLayer =
    new ColumnGroupHeaderLayer(this.colHeaderLayr,this.bodyLayr.getSelectionLayer(),this.colGrpModel,false);

this.colGrpHeaderLayer.setCalculateHeight(true);

// Composite layer
CompositeLayer compositeGridLayer = new CompositeLayer(1,2);

//Group by header layer
this.groupByHeaderLayer = new GroupByHeaderLayer(groupByModel,this.paramFilterGridLayer,this.filterGridLayer.getColumnHeaderDataProvider());   

compositeGridLayer.setChildLayer(GroupByHeaderLayer.GROUP_BY_REGION,this.groupByHeaderLayer,0);

compositeGridLayer.setChildLayer("Grid",this.filterGridLayer,1);

这是 groupBy 配置:

configRegstry.registerConfigAttribute(
    GroupByConfigAttributes.GROUP_BY_CHILD_COUNT_PATTERN,"[{0}] - ({1})");

configRegstry.registerConfigAttribute(
    GroupByConfigAttributes.GROUP_BY_HINT,"Drag columns here");

// To implement text wrapping in  group by header region  
configRegstry.registerConfigAttribute(
    CellConfigAttributes.CELL_PAINTER,new TextPainter(true,true,2),DisplayMode.NORMAL,GroupByHeaderLayer.GROUP_BY_REGION);

解决方法

简短回答:目前不支持。

长答案: 你误解了几件事。

  1. 文本换行意味着如果单元格中没有足够的空间,则会动态添加新行。由于 GroupByHeader 实际上是一个跨越整个宽度的单元格,因此单元格宽度永远不会超过以强制文本换行。
  2. TextPainter 是一个 ICellPainter,因此它用于呈现单元格。
  3. GroupByHeader(虽然是跨区单元格)不使用默认单元格绘制器。它使用特殊的 GroupByHeaderPainter,因为它需要检查 GroupByModel 并为每个条目呈现片段。该画家目前不支持换行。并且它不会在内部使用其他 ICellPainter

这意味着,如果您需要在 GroupByHeader 中支持换行,则需要扩展 GroupByHeaderPainter。作为一个开源项目,我们喜欢贡献。 :)

如果您想在 GroupByHeader 中添加某种文本换行,您需要以某种方式指定何时换行。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...