How do you get the default column widths used in a table

I’m working on exporting a UI table component to a PDF, and want to set the column widths in the PDF table the same as what is displayed in the UI table. Once a user resizes a column, I can set the columns in the PDF to show up as they are in the UI (based on getColumnWidth). However, if the user doesn’t resize a column all the column widths are calculated by the theme. Then I don’t know how to set the column widths in the PDF.

Is there a way to get the column widths that the theme calculates and displays? i.e. access the theme calculated column widths on the backend?




I don’t think this is currently possible. If no column widths are set, the widths are calculated in VScrollTable (the client-side class of table) based on available width and size of the contents in those columns. The calculated values are never communicated back to the server.

If you’re not afraid of a little client-side coding, I think it would be quite easy to create an extension for Table that would (on demand) find the Table’s header bar, step through the column header elements, measure each one and send the results back to the server.


Thanks for the quick response. I think I’ll just initialize the column widths instead, seems like less work.

Hi Teppo can you give an example about how to get table header and measure it?


Any success?