Table Header add Checkbox to Cell Causes Failed PDF

Posted by: mlocke on 11 May 2023, 6:17 am EST

    • Post Options:
    • Link

    Posted 11 May 2023, 6:17 am EST - Updated 11 May 2023, 6:22 am EST

    Hello! I’m attempting to add a checkbox to my header row of a table on an ActiveReport RDL Multi-Section report. I can add a checkbox to a data row and it works fine, but in the header the PDF generates when I export it but it does not open due to an error (see screenshot).

    Here’s my code to add a checkbox to the header.

                    Table table = new Table();
                    table.Name = "tblCompensationDetails";
                    //create header row
                    TableRow trHeader = new TableRow();
                    trHeader.Height = "1.25cm";
                    table.Height += "1.25cm";
    		TableCell tc = new TableCell();
    		TableColumn tcol = new TableColumn();
    
    		bool isTrue= true;
                    cb.Name = "chkHeader148";
                            cb.Value = "1-48";
                            cb.Checked = ExpressionInfo.FromString(isTrue.ToString());
                            cb.Style.PaddingBottom = cb.Style.PaddingLeft = cb.Style.PaddingRight = cb.Style.PaddingTop = ExpressionInfo.FromString("2pt");
                            cb.Style.VerticalAlign = ExpressionInfo.FromString("Middle");
                            cb.Style.FontSize = ExpressionInfo.FromString("7pt");
                            cb.Style.FontWeight = ExpressionInfo.FromString("Bold");
                            cb.Style.WrapMode = ExpressionInfo.FromString("WordWrap");
                            tc.ReportItems.Add(cb);
    		     tcol.Width = "0.50in";
                        tcol.FixedHeader = true;
                        table.TableColumns.Add(tcol);
                        trHeader.TableCells.Add(tc);

    I use the same exact code for the detail row (except I assign the checked value to a field on the report) and it doesn’t break. But in the header it is breaking. Is there some other setting that needs to be done for header checkboxes?

    Thanks!

  • Posted 15 May 2023, 8:49 pm EST

    Hi Melissa,

    Please make sure to add a Header TableRow to the Table as well. See below code:

                //Add a row in Table Header
                table.Header.TableRows.Add(trHeader);
    

    For reference, I have also attached a sample application along with.

    When designing page report with code, for debugging I would suggest you save the report file using pageReport.Save method and then create the required report using the Standalone Designer and then you can compare the two report files XML by opening the report files in a Text Editor. Also by saving the report created at run time you can also open it in the StandAlone Designer to see whether the report outcome is a valid PageReport or not.

    For example, in this case I received an error when previewing the report saying that there is no Table Header, Footer or Detail section so I added a header and that fixed the issue.

    RunTimeRDLReport.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels