Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header not working as expected #884

Open
davideTES opened this issue May 6, 2024 · 3 comments
Open

Header not working as expected #884

davideTES opened this issue May 6, 2024 · 3 comments

Comments

@davideTES
Copy link

Describe the bug
I'm trying to generate a report with a different header on the first page. The headers on page 1 and page 2 are fine, but from page 3, the header is different from what I expected.

To Reproduce
This is the ComposeHeader method

private void ComposeHeader(IContainer container)
{
    container.Background(Colors.Grey.Lighten3).Border(1).Column(column =>
    {
        column.Item().Table(table =>
        {
            table.ColumnsDefinition(columns =>
            {
                column.Spacing(10);

                columns.RelativeColumn();
                columns.RelativeColumn();
            });

            table.Cell().Row(1).Column(1)
                .Component(new HeaderLabelTemplate("Shared", "Valore"));
            table.Cell().Row(1).Column(2)
                .Component(new HeaderLabelTemplate("Shared", "Valore"));
        });

        column.Item().ShowOnce().Table(table =>
        {
            table.ColumnsDefinition(columns =>
            {
                column.Spacing(10);

                columns.RelativeColumn();
                columns.RelativeColumn();
            });

            table.Cell().Row(1).Column(1)
                .Component(new HeaderLabelTemplate("Inizio Lotto", "Valore"));
            table.Cell().Row(1).Column(2)
                .Component(new HeaderLabelTemplate("Lotto", "Valore"));

            table.Cell().Row(2).Column(1)
                .Component(new HeaderLabelTemplate("Fine Lotto", "Valore"));
            table.Cell().Row(2).Column(2)
                .Component(new HeaderLabelTemplate("Tipologia", "Valore"));
        });
    });
}

Expected behavior
I expect to find both tables on the first page and only the first one from page 2 onwards.

Screenshots
Header of page 1
image

Header of page 2
image

Headers of subsequent pages
image

Environment
I'm using version 2024.3.2 of the library and Windows 11 (x64).

@davideTES
Copy link
Author

Moving the .ShowOnce() after Cell(), everything works as expected.

private void ComposeHeader(IContainer container)
{
    container.Background(Colors.Grey.Lighten3).Border(1).Column(column =>
    {
        column.Item().Table(table =>
        {
            table.ColumnsDefinition(columns =>
            {
                column.Spacing(10);

                columns.RelativeColumn();
                columns.RelativeColumn();
            });

            table.Cell().Row(1).Column(1)
                .Component(new HeaderLabelTemplate("Shared", "Valore"));
            table.Cell().Row(1).Column(2)
                .Component(new HeaderLabelTemplate("Shared", "Valore"));
        });

        column.Item().Table(table =>
        {
            table.ColumnsDefinition(columns =>
            {
                column.Spacing(10);

                columns.RelativeColumn();
                columns.RelativeColumn();
            });

            table.Cell().Row(1).Column(1).ShowOnce()
                .Component(new HeaderLabelTemplate("Inizio Lotto", "Valore"));
            table.Cell().Row(1).Column(2).ShowOnce()
                .Component(new HeaderLabelTemplate("Lotto", "Valore"));

            table.Cell().Row(2).Column(1).ShowOnce()
                .Component(new HeaderLabelTemplate("Fine Lotto", "Valore"));
            table.Cell().Row(2).Column(2).ShowOnce()
                .Component(new HeaderLabelTemplate("Tipologia", "Valore"));
        });
    });
}

Is this behavior intentional?

@MarcinZiabek
Copy link
Member

Thank you for finding and reporting this issue 😄

Indeed, this behavior is not correct. I investigated the problem, and I already understand the root cause. I am working on a fix.

Do you know that you can simplify your code by replacing tables with a simpler element called Row?

.Row(row =>
{
    row.RelativeItem().Component(new HeaderLabelTemplate("Shared", "Valore"));
    row.RelativeItem().Component(new HeaderLabelTemplate("Shared", "Valore"));
});

@davideTES
Copy link
Author

Thank you so much for the work you do with this library and for the advice on simplifying the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants