We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Nested Tables Support

Is it possible to use nested tables with Syncfusion.Pdf? I have looked through the documentation and could not find anything. Additionally, I tried some things on my own, but when the table was rendered, the cell I was expecting a nested table to be in instead had "Syncfusion.Pdf.Tables.PdfLightTable" in it.

Simplified, here is the code I used:

PdfLightTable outerTable = new PdfLightTable();
outerTable.DataSourceType = PdfLightTableDataSourceType.TableDirect;

outerTable.Columns.Add(new PdfColumn("Column 1"));
outerTable.Columns.Add(new PdfColumn("Column 2"));

PdfLightTable innerTable = new PdfLightTable();
innerTable.DataSourceType = PdfLightTableDataSourceType.TableDirect;

innerTable.Columns.Add(new PdfColumn("Column 1"));
innerTable.Columns.Add(new PdfColumn("Column 2"));

innerTable.Rows.Add(new object[] { "Cell 1.1", "Cell 1.2" });

outerTable.Rows.Add(new object[] { "Cell 1", innerTable });

5 Replies

SS Sri Subhashini M Syncfusion Team July 6, 2009 11:01 AM UTC

Hi Steve,

Thank you for your interest in Essential PDF.

Nested Table

We can draw the table inside to another table by subscribing BeginCellLayout event handler.

Kindly refer the below code snippet to render the nested table,

// Event handler
table.BeginCellLayout +=new BeginCellLayoutEventHandler(table_BeginCellLayout);


void table_BeginCellLayout(object sender, BeginCellLayoutEventArgs args)
{
if (args.CellIndex == 2 && args.RowIndex == 1)
{
DataTable dt = new DataTable();
dt.Columns.Add("Column 1");
dt.Columns.Add("Column 2");

dt.Rows.Add(new string[] { "Cell 1.1", "Cell 1.2" });
dt.Rows.Add(new string[] { "Cell 2.1", "Cell 2.2" });

PdfLightTable t1 = new PdfLightTable();
t1.DataSourceType = PdfLightTableDataSourceType.External;
t1.DataSource = dt;

t1.Draw(args.Graphics, args.Bounds.Location,args.Bounds.Width);
}
}

Please do find the sample from the below specified location and let me know if this helps,

http://files.syncfusion.com/samples/pdf.windows/PDF_F82540.zip

Regards,
Suba


SP Steve Platz July 8, 2009 02:12 PM UTC

That worked great for inserting a table in that cell, but now I'm running into the problem of the cell not growing in height to fit the contents of the nested table. I looked at the example you attached and it seemed the case was the same there as well. Is this possible?


SP Steve Platz July 8, 2009 02:13 PM UTC

I also meant to add that the nested table has its contents spill over into the adjacent cells, causing things to render incorrectly.


SP Steve Platz July 8, 2009 02:30 PM UTC

Better yet, is there a way to do row spans at all? I've found column spans in the documentation, but no mention of row span.


SS Sri Subhashini M Syncfusion Team July 10, 2009 10:42 AM UTC

Hi Steve,

Sorry for the delay in getting back with you.

Nested Table and RowSpan feature

We can draw the nested table and set the row span easily by using PdfGrid method and the Pdfgrid feature is available with our latest Essential Studio 2009 Volume.3 RC. This is available for download from the below location.

http://www.syncfusion.com/support/forums/general/86322/essential-studio-2009-vol3-rc-v73018-available-for-download

Could you please do find the sample which demonstrates the above mentioned feature and let me know if this helps?
http://files.syncfusion.com/samples/PDF.Windows/F82540.zip

Regards,
Suba

Loader.
Live Chat Icon For mobile
Up arrow icon