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

PdfGrid: size grid to content

Is it possible to resize a pdfGrid columns to content?
In Xaml I'd do something like:
Column Width = "*"
Column Width = "Auto"
Column Width = "Auto"

ie: Column 1 would stretch to available space
Column 2 & 3 would auto-align to content.

6 Replies

SK Surya Kumar Syncfusion Team July 4, 2017 12:03 PM UTC

Hi Malcolm, 
 
Thank you for using Syncfusion products. 
 
When width of one of the column is set then, other columns will resize automatically in PdfGrid, please refer the below UG documentation link for customization of columns in PdfGrid. 
 
Documentation link: 
 
Please let us know if you need any further information in this. 
 
Regards, 
Surya Kumar 



MJ Malcolm Jack July 4, 2017 12:43 PM UTC

Hi Surya,

That's handy if you know what the max length of the content will be.

But with runtime data, you don't know the max content width at design time, so you can't set column width.

Would be great of the was the "Auto" / "*" convention like in xaml - but I assume there isn't.

I would imagine the best way to do this would be to cycle through the content, and find the max length using MeasureString on the text, and then set the column width accordingly?

Malcolm



SK Surya Kumar Syncfusion Team July 5, 2017 07:22 AM UTC

Hi Malcolm, 
  
We have created the sample as per your requirement for resizing the width of the PdfGrid column as per the maximum width of contents in the respective column, by iterating through each contents and setting the string with maximum width as the column width. 
  
Please find the sample link below: 
  
Please find the final output document from the link below: 
  
Let us know if you need any further information in this. 
  
Regards, 
Surya Kumar 



MJ Malcolm Jack July 5, 2017 08:44 PM UTC

That's fantastic - thx :)

Would be great if in future releases this was easier to do - I would imagine it's a fairly common requirement for column widths.




MJ Malcolm Jack July 5, 2017 09:32 PM UTC

Hi Surja,

I tried to apply the same logic to the PdfLightTable column - but it doesn't have the same effect.

Is there a bug with the pdfLightTable?

You can find a repo with sample code here


Malcolm



SK Surya Kumar Syncfusion Team July 7, 2017 11:32 AM UTC

  
Hi Malcolm,  
 
 
We were able to reproduce the issue and we have confirmed this as bug and logged a report on this. Also, we have created a support incident under your account to track the status of this issue.  
 
                                                      
Please log on to our support website to check for further updates.  
 
Please let us know if you have any questions.  
  
 
Thanks,  
Surya Kumar.  


Loader.
Live Chat Icon For mobile
Up arrow icon