0

我想在标题标题中实现文本换行。我还在顶部列标题层上添加了逐层文本换行在具有以下配置的按标题区域中不起作用。如何在这种情况下实现文本换行

// 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, 0);

compositeGridLayer.setChildLayer("Grid", this.filterGridLayer, 0, 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);
4

1 回答 1

2

简短回答:目前不支持此功能。

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

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

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

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

于 2021-01-08T07:33:58.610 回答