I have a VF custom component with attribute called chartHeight.
I need to assign chartHeight a value from the VF page the component resides in, and this value should be screen.availHeight retrived using from JS.
How can I pass screen.availHeight as the atrribute's value?
<c:PartitionChart JsonData="{!JsnString}" chartHeight=**<need to pass this>** chartWidth="800"/>
<apex:attribute name="chartHeight" description="Chart Height" type="integer" required="true" />
Best Answer
On principle, it's a shame to hand the browser dimensions to a server-side component.
But you can definitely do this as a multi stage process if you really have to:
The general idea is to grab the window size of the browser, transmit it to the server in a form submission and then draw the chart using a
{!Height}
controller property, like this:The controller just provides a dumb target for the height to hang around in the viewstate.