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
vasvas 

Displaying related objects fields in a free form instead of columns

I have a custom object with a lookup to Opportunity, so I can display the custom object's records in the related list section of opportunity. I'm trying to display the fields of this custom object record in a free form on the opportunity page (just like any other fields of opportunity) as opposed to the columns which seem to be the default for dataTable or pageBlockTable.

 

To illustrate the problem, this is how its currently displayed-

 

Opportunity page:

.... some opportunity fields here...

 

Related list- Custom object

field1      field2        field3          field4

----------------------------------------

value1    value2      value3        value4

valueA    valueB      valueC        valueD

 

 

I want to display the custom object records (one block for every record) like this-

 

field1:  value1

field2:  value2

field3:  value3

field4:  value4

 

field1:  valueA

field2:  valueB

field3:  valueC

field4:  valueD

 

 

Any suggestions? Thanks in advance.

 

 

jwetzlerjwetzler
You could use apex: dataList or apex: repeat to iterate over the values instead.  dataList will create bullet points, repeat will just repeat your block of code for each object you iterate over.
vasvas

Thanks for the quick response. With apex:repeat, is there a way to use some conditionals? For example, I want to filter out some records from the display based on certain condition. Is that possible?

 

Thanks again.

jwetzlerjwetzler

I think the smartest way to do it is filter it out in an Apex class.  So value="{!records}" where getRecords only returns the list of records you want to display.

 

Technically you could surround everything inside the repeat with an outputPanel and set the rendered attribute of your outputPanel to some condition, but I would recommend the first option.  It would probably be more efficient anyway. 

vasvas
I was just trying to avoid writing a custom controller, but I agree that its the better way to do it. Thank you so much.