DBCrossView Header Height

edited 2:14PM in FastReport VCL 5
Hi

I am trying to create a crosstab report with word-wrapped headers - it should look like

https://drive.google.com/file/d/0B2frzc9m9x...iew?usp=sharing

but the rows overwrite the headers, as here:

https://drive.google.com/file/d/0B2frzc9m9x...iew?usp=sharing.

No matter what I try, I cant get the Rows to flow correctly after the Headers.

In this example, the Header height is set in code:

procedure DBCross1OnCalcWidth(ColumnIndex: Integer; ColumnValues: Variant; var Width: Extended);
begin
//Width := 60;
if ColumnIndex = 0 then
Width := 50;
if ColumnIndex = 5 then
Width := 70;
if ColumnIndex >= 6 then
Width := 70;
end;

procedure DBCross1OnCalcHeight(RowIndex: Integer; RowValues: Variant; var Height: Extended);
begin

end;

procedure DBCross1Cell0OnBeforePrint(Sender: TfrxComponent);
begin

end;

procedure DBCross1OnBeforePrint(Sender: TfrxComponent);
begin

end;


procedure DBCross1OnPrintColumnHeader(Memo: TfrxMemoView; HeaderIndexes, HeaderValues, Value: Variant);
begin
Memo.Height := 70;
end;

procedure DBCross1Column0OnBeforePrint(Sender: TfrxComponent);
begin

end;

Any help, please...

Jon

Comments

  • edited 2:14PM
    OK, the problem appears to be that the header memo height is not calculated until the onprint event. Unfortunately, the position calculations for the subsequent rows are done way before this event - so the headers print correctly, but the subsequent rows print to follow the default height of the header.

    Fixed with a kludge in

    procedure TfrxCrossColumnHeader.CalcBounds;

    begin
    DoAdjust(Self);

    SetLength(LevelHeights, FLevelsCount + 1);

    Items := AllItems;

    // calculate height of each row
    for i := 0 to Items.Count - 1 do
    begin
    Item := Items;
    l := Item.Level;

    // cell headers always adjust the last level height
    if Item.FIsCellHeader then
    l := FLevelsCount
    // don't count total elemens unless they are on last level.
    // such elements will be adjusted later
    else if Item.IsTotal then
    if l <> FLevelsCount - 1 then continue;

    if Item.Memo.Height > Item.FSize.Y then
    Item.FSize.Y := Item.Memo.Height + (Item.Memo.GapY * 2) + (TFrxFrame(Item.Memo.Frame).ShadowWidth * 2) +
    (TFrxFrame(Item.Memo.Frame).Width * 2);

    if l >= 0 then
    if Item.FSize.Y > LevelHeights[l] then
    LevelHeights[l] := Item.FSize.Y;
    end;

    which works for me in this instance.

    Could someone from FR please provide a better fix?

    Thanks

    Jon
  • edited 2:14PM
    JonB wrote: »
    OK, the problem appears to be that the header memo height is not calculated until the onprint event. Unfortunately, the position calculations for the subsequent rows are done way before this event - so the headers print correctly, but the subsequent rows print to follow the default height of the header.

    ...

    Could someone from FR please provide a better fix?

    Thanks

    Jon
    IMO it would be enough to add new CrossTab property MaxHeight / MinHeight (similar to MaxWidth / MinWidth).
    These new properties should apply not only to cells but to column headers as well.

    This would help to solve my problem too as I descripted in [topic="13107"]How to set Column Header height[/topic]

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.