Inserting Table inside Table Cell.

7 posts, 0 answers
  1. jaipal
    jaipal avatar
    10 posts
    Member since:
    Mar 2018

    Posted 17 Jul 2018 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
    10 posts
    Member since:
    Mar 2018

    Posted 19 Jul 2018 in reply to jaipal Link to this post

    I was looking somthing simillar thos attached implementation.

     

    Regards, 

    JP

  3. Georgi
    Admin
    Georgi avatar
    52 posts

    Posted 20 Jul 2018 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
    10 posts
    Member since:
    Mar 2018

    Posted 23 Jul 2018 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
    52 posts

    Posted 26 Jul 2018 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

  6. Kong
    Kong avatar
    6 posts
    Member since:
    Feb 2017

    Posted 21 Dec 2020 in reply to Georgi Link to this post

    How do you style a single cell? For instance, I need to add bottom border to a single cell in a table.
  7. Martin
    Admin
    Martin avatar
    140 posts

    Posted 22 Dec 2020 Link to this post

    Hello Kong,

    I already answer your question in the support ticket you have opened and will place the answer here as well.

    You can create a table containing a single cell with a bottom border set in the following manner: 

    Table table = new Table();
    TableRow firstRow = table.Rows.AddTableRow();
    TableCell firstCell = firstRow.Cells.AddTableCell();
    firstCell.PreferredWidth = 50;
    Block firstCellBlock = firstCell.Blocks.AddBlock();
    firstCellBlock.GraphicProperties.FillColor = RgbColors.White;
    firstCellBlock.InsertText(".");
    Border border = new Border(1, RgbColors.Black);
    firstCell.Borders = new TableCellBorders(null, null, null, bottom: border);

    I have to mention, currently, there is a limitation in the Table object (the setting of a table row height is not supported) so if you create a table row with an empty table cell the bottom border would be drawn in place of the top border because the table height won't be set (the table cell starting point is the top left corner). The border would be correctly drawn if the table cell has content (in the provided code snippet we are setting the color of this content to white in order to not be visible). We have an item logged in our backlog to implement an option for setting the height to table rows: PdfProcessing: Implement an option for setting the height to table rows. You can cast your vote for the implementation as well as subscribe to the task by clicking the Follow button so you can receive updates when its status changes.

    Ones you created the table you can insert it in the document using both RadFixedDocumentEditor`s InsertTable() method and FixedContentEditor`s DrawTable() method.

    Regards,
    Martin
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Back to Top