function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ChrissieChrissie 

Limit rows and Dynamically set the height of a VF Page ?

We are creating a small VF page that will be placed above the Account detail section, this will display specific data from a single related list, and have come up against some challenges:

 

Challenge 1)  limit to the number of rows displayed, they only want to see a set number of records - "show Up To 5"  
These would be the most recent.

 

Challenge 2)  Users do not want to scroll, so can we dynamically set the height of the VF page so that users don't see unnecessary white space?

 

For example- when there are 4 records in the related list show all 4 rows, and when there is only 1 record than only show 1 row without the wasted space beneath it  

 

The developer is unsure how to accomplish this.  Can it be done? IF so, any examples?

nickwick76nickwick76

Hi, 

About Challenge 1)

 

Hope I understood you right here.

When you populate the VF-page with records you are probably using a pageblocktable or a repeat component which iterates over a list from the controller. This method from the controller probably does a SOQL select. Use 'limit 5' at the end of this soql select to only get 5 results. And to get the most recent records you can add 'order by createdDate' and then 'asc' or 'desc' to sort them with the latest first or last.

 

Challenge 2) Don't know of a way to set the height dynamically.

 

// Niklas