I have figured out how to determine the size of a webgrid at the client-side but can't seem to figure out how to get that information at the server. I am not setting the width or height of the grid but letting it figure it out on it's own (as my number of columns are dynamic).
On the client side I take the width of the frame element that surrounds the grid:
function grdData_InitializeLayoutHandler(gridName){ var oGrid = igtbl_getGridById(gridName); var intWidth = new Number(oGrid.Element.style.width.replace('px','')); autofitIframe('iframeReport',intWidth);}
(Note that I needed to know the actual width on the client side so I could resize the calling parent frame accordingly.)
Can anyone point me in the right direction on the server side? I need to pass the grid width into a function that spits my webpage out to a pdf as an image (using ABCpdf from WebSupergoo) & it would help if I knew the width of grid so I can choose appropriate paper sizes... Note that the size of my webpage will always stretch out to the size of the grid.
Please help! Thanks!
Tina
Yes, if you fix the fonts / width of the columns this will work, but you have no control on the font-size / other settings on the client browser, so this may not always be 100% acurate.
Thanks for the quick reply!
As it turns out, I am just going to do a count of the columns that are dynamic & figure out page sizes that way...
There's no direct way to determine what size the WebGrid is on the server. The server doesn't know what settings are on the client machine, including font settings that can be configured on the browser, and some of these settings can affect the resulting height.
The closest solution I've seen is to calculate the width and height client-side (similar to the code you already have), store the results in a hidden field, and use those values on the server. Note that you may also need to retrieve other information, such as font settings, for the width and height to be meaningful.