I am fairly new to Visualforce and I have been trying to create a Related List in VF on object Employee__c
to show all of the devices with an ‘Active’ status (Status__c
field on Device__c
object).
There is a master-detail relationship on Device__c
to Employee__c
. The child relationship name is Relatedemployees
.
I also tried to make sure the edit and delete buttons on the Related List do not appear.
Here are my codes:
Page:
<apex:page standardController="Employee__c" extensions="ActiveDevices">
<apex:detail relatedList="true">
<apex:relatedList id="CustomList" list="Relatedemployees" title="Active Devices"
subject="{!actDevices}">
</apex:relatedList>
<style type="text/css">
.actionColumn {display:none; visibility:hidden}
</style>
</apex:detail>
</apex:page>
Class:
public class ActiveDevices {
public List<Device__c> getactDevices() {
List<Device__c> actDevices =
[SELECT Name__c, Type__c, Serial_Number__c, Status__c,
FROM Device__c WHERE Status__c == 'Active' ];
return actDevices;
}
}
Best Answer
This worked for me: