This is a migrated thread and some comments may be shown as answers.

Height Issues with TextBox in Table

2 Answers 36 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Craig
Top achievements
Rank 1
Craig asked on 23 Sep 2013, 06:37 PM
Hi there,

I have noticed something extremely odd. It seems like TextBox or is choosing heights in unexpected ways when they are children of a table.
What I have is a loop iterates over some data rows and adds TextBoxes to a table. The reason I am doing this is because by requirements are to build a report based on report configuration data stored in the data base. So a report template would not work for me (as most of your examples are).

So what I have is the following.

private void BuildReport()
{
    Table tbl = new Table();
 
    Unit columnWidth = Unit.Inch(0.5);
    tbl.Body.Columns.AddRange(new TableBodyColumn[] {
        new TableBodyColumn(columnWidth),
        new TableBodyColumn(columnWidth),
        new TableBodyColumn(columnWidth),
        new TableBodyColumn(columnWidth),
        new TableBodyColumn(columnWidth),
        new TableBodyColumn(columnWidth),
        new TableBodyColumn(columnWidth),
        new TableBodyColumn(columnWidth),
        new TableBodyColumn(columnWidth),
        new TableBodyColumn(columnWidth),
        new TableBodyColumn(columnWidth),
        new TableBodyColumn(columnWidth)
    }.AsEnumerable());
 
    tbl.Style.BorderWidth.Top = new Unit(1D, UnitType.Pixel);
    tbl.Style.BorderWidth.Bottom = new Unit(1D, UnitType.Pixel);
    tbl.Style.BorderWidth.Left = new Unit(1D, UnitType.Pixel);
    tbl.Style.BorderWidth.Right = new Unit(1D, UnitType.Pixel);
 
    tbl.Style.BorderStyle.Top = BorderType.Solid;
    tbl.Style.BorderStyle.Bottom = BorderType.Solid;
    tbl.Style.BorderStyle.Left = BorderType.Solid;
    tbl.Style.BorderStyle.Right = BorderType.Solid;
 
    for (int idx = 0; idx < tbl.Body.Columns.Count; idx++)
    {
        TableGroup group = new TableGroup();
        tbl.ColumnGroups.Add(group);
    }
 
    this.DetailSection.Items.AddRange(new ReportItemBase[] { tbl });
    int rowNumber = 0;
    for (int idx = 0; idx < fieldComps.Count; idx++)
    {
        ModelTableFieldComposition_Flatten field = fieldComps[idx];
        GetLabelRow(field, ds, tbl, ref rowNumber);
    }
}
 
private void GetLabelRow(ModelTableFieldComposition_Flatten field, Table tbl, ref int rowNumber)
{
    TableGroup tableGroupRow = new TableGroup();
 
    tbl.RowGroups.Add(tableGroupRow);
    tbl.Body.Rows.Add(new TableBodyRow(Unit.Inch(0.1D)));
 
    int colIndex = 0;
 
    Telerik.Reporting.TextBox labelTextBox = new TextBox();
    labelTextBox.Name = "labelField";
    labelTextBox.Size = new SizeU(Unit.Inch(0.1), Unit.Inch(0.1));
    labelTextBox.Style.BorderStyle.Bottom = Telerik.Reporting.Drawing.BorderType.Solid;
    labelTextBox.Style.BorderStyle.Left = Telerik.Reporting.Drawing.BorderType.Solid;
    labelTextBox.Style.Font.Name = "Segoe UI";
    labelTextBox.Style.Font.Size = Unit.Point(10);
    labelTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle;
 
    labelTextBox.Value = field.DisplayName;
    labelTextBox.Visible = field.FieldLabelVisible;
 
    labelTextBox.Style.BackgroundColor = Color.Wheat;
    labelTextBox.Style.Color = Color.Black;
 
    tbl.Body.SetCellContent(rowNumber, 0, labelTextBox, 0, field.ReportFieldLabelColumnSpan);
    tbl.Items.AddRange(new ReportItemBase[] { labelTextBox });
 
    int columnSpanCounter = field.ReportFieldLabelColumnSpan;
 
    colIndex = field.ReportFieldLabelColumnSpan;
 
    while (columnSpanCounter < 12)
    {
        Telerik.Reporting.TextBox emptyLabelTextBox = new TextBox();
        emptyLabelTextBox.Name = "emptyField";
        emptyLabelTextBox.Size = new SizeU(Unit.Inch(0.1), Unit.Inch(0.1));
        emptyLabelTextBox.Visible = true;
        emptyLabelTextBox.Value = string.Empty;
 
        emptyLabelTextBox.Style.BorderStyle.Bottom = Telerik.Reporting.Drawing.BorderType.Solid;
        emptyLabelTextBox.Style.BorderStyle.Left = Telerik.Reporting.Drawing.BorderType.Solid;
        emptyLabelTextBox.Style.Font.Name = "Segoe UI";
        emptyLabelTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle;
 
        tbl.Body.SetCellContent(rowNumber, colIndex, emptyLabelTextBox, 0, 1);
        tbl.Items.AddRange(new ReportItemBase[] { emptyLabelTextBox });
 
        columnSpanCounter++;
        colIndex++;
    }
 
    rowNumber++;
}

2 Answers, 1 is accepted

Sort by
0
Craig
Top achievements
Rank 1
answered on 26 Sep 2013, 09:31 PM
Another thing I noticed is the mere changing of report document from PDF to DOCX causes different sizings.
I'm hoping Telerik can help shed some light on why there would be different heights and how sizing is chosen.
0
Stef
Telerik team
answered on 27 Sep 2013, 12:11 PM
Hello Craig,

You can find attached a report definition(Report1) created with the provided code snippet. We have modified the code based on the generated by the report designer code in Report2 - a sample report definition created with the provided designer and static data to test how the Table item definition looks. Notice groups have distinct Name and TextBox items are resized based on the amount of cells each occupies.

Generally, whenever you create dynamic items definitions test creating a simple layout using the designer and then reuse the code as need.

Let us know if you have any further questions.

Regards,
Stef
Telerik

Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

Tags
General Discussions
Asked by
Craig
Top achievements
Rank 1
Answers by
Craig
Top achievements
Rank 1
Stef
Telerik team
Share this question
or