Inserting Table inside Table Cell.

5 posts, 0 answers
  1. jaipal
    jaipal avatar
    9 posts
    Member since:
    Mar 2018

    Posted 17 Jul Link to this post

     Hi All,

    For the PDF Processing , I have to attache a  single table row and  there will be two cells.(some thing which is simillar to the attachment).

    1.First  cell  constitutes of Question.

    2.Second Sells constitues of a table.

     

    It his scenario possible?

     

    Regards,

    JP

     

  2. jaipal
    jaipal avatar
    9 posts
    Member since:
    Mar 2018

    Posted 19 Jul in reply to jaipal Link to this post

    I was looking somthing simillar thos attached implementation.

     

    Regards, 

    JP

  3. Georgi
    Admin
    Georgi avatar
    11 posts

    Posted 20 Jul Link to this post

    Hello Jaipal,

    To create a TableCell instance in PdfProcessing which occupies a specified number of rows you can set the RowSpan property. For example:
    TableCell cell = row.Cells.AddTableCell();
    cell.RowSpan = 2; // number of rows to occupy
    Block cellBlock = cell.Blocks.AddBlock();
    cellBlock.VerticalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.VerticalAlignment.Center;
    cellBlock.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
    cellBlock.InsertText("Cell Value");

    You can set default styling to all cells in a table using the Table's DefaultCellProperties property. In order to set alternating background color for Table rows, you should manually apply the Background color for the cells in each alternating row:
    Table table = new Table();
     
    Border border = new Border();
    table.Borders = new TableBorders(border);
    table.DefaultCellProperties.Borders = new TableCellBorders(border, border, border, border);
    table.DefaultCellProperties.Background = mainColor;
     
    TableRow firstRow = table.Rows.AddTableRow();
    TableCell cell = firstRow.Cells.AddTableCell();
    Block block = cell.Blocks.AddBlock();
    block.InsertText(new FontFamily("Arial"), FontStyles.Normal, FontWeights.Bold, "First Heading Cell");
     
    cell = firstRow.Cells.AddTableCell();
    block = cell.Blocks.AddBlock();
    block.InsertText(new FontFamily("Arial"), FontStyles.Normal, FontWeights.Bold, "Second Heading Cell");
     
    TableRow secondRow = table.Rows.AddTableRow();
    cell = secondRow.Cells.AddTableCell();
    cell.Background = alternateColor;
    block = cell.Blocks.AddBlock();
    block.InsertText("First Value Cell");
     
    cell = secondRow.Cells.AddTableCell();
    cell.Background = alternateColor;
    block = cell.Blocks.AddBlock();
    block.InsertText("Second Value Cell");


    When a table is generated, it could be inserted in the PDF document using the RadFixedDocumentEditor's InsertTable() method as can be seen in the Drawing Table with RadFixedDocumentEditor section of the documentation.

    I hope this helps.

    Regards,
    Georgi
    Progress Telerik

  4. jaipal
    jaipal avatar
    9 posts
    Member since:
    Mar 2018

    Posted 23 Jul in reply to Georgi Link to this post

    Georgi,

    Thank you for the inputs , we were able to solve much complicated scenarios invoiving tables , Cells and Blocks but this is where we are struck right now.I am looking for a more specific solution simillar to what is ther in the attachement. 

    I can give both column spans and Row Spans but what i am looking at is first coloumn needs to have certain content and rest of the coloumns would be having rows.Is this possible ?

    Regards,

    JP

  5. Georgi
    Admin
    Georgi avatar
    11 posts

    Posted 26 Jul Link to this post

    Hello JP,

    To accomplish the desired result, you can set the TableCell.RowSpan property of the first cell to the number of the table rows. This way you can set your own content which will occupy through the rows of the entire table:
    TableCell leftSpannedCell = firstRow.Cells.AddTableCell();
    leftSpannedCell.RowSpan = table.Rows.Count;
    leftSpannedCell.InsertText("Representatives from each country");

    After this, you can add the preceding text cell by adding cell on the first row and setting the TableCell.ColumnSpan property to the number of remaining columns:
    TableCell topSpannedCell = firstRow.Cells.AddTableCell();
    topSpannedCell.ColumnSpan = 3; // the number of columns to occupy
    topSpannedCell.InsertText("This a text before Table");

    Please, note that setting the table rows height is currently not implemented in PdfProcessing. We have logged feature request in our feedback portal: PdfProcessing: Implement option for setting height to table rows, where you can subscribe to be notified for any status updates and vote to increase the priority. Alternatively, you can apply a certain row height by setting the TableCell.Padding property:
    topSpannedCell.Padding = new Thickness(0, 10, 0, 10);

    Please, find the attached solution, which creates a sample table similar to the attachment you have provided.

    I hope this helps.

    Regards,
    Georgi
    Progress Telerik

Back to Top