You need to sign in to do that
Don't have an account?
Prateek Aneja 2
Child object record display
I have created an object "Employee" and child object "Customer".
I have written an Apex Code that'll fetch details of employees and customers:
**********************************************************************************************************************
public class contrBinding {
public List<Employee__c> employee{get;set;}
public List<Employee__c> getEmpl(){
employee = [select Name, First_Name__c, Last_Name__c, (select Name, First_Name__c, Last_Name__c from Customers__r) from Employee__c limit 10];
return employee;
}
}
*******************************************************************************************
This is the Visualforce page code:
*******************************************************************************************
<apex:page controller="contrBinding" sidebar="false">
<apex:form >
<apex:pageBlock title="Employee Details">
<apex:pageBlockTable value="{!Empl}" var="emp">
<apex:column value="{!emp.Name}"/>
<apex:column value="{!emp.First_Name__c}"/>
<apex:column value="{!emp.Last_Name__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
*******************************************************************************************************
Can anyone tell me how can I bring the Customer recods on Visualforce page?
I have written an Apex Code that'll fetch details of employees and customers:
**********************************************************************************************************************
public class contrBinding {
public List<Employee__c> employee{get;set;}
public List<Employee__c> getEmpl(){
employee = [select Name, First_Name__c, Last_Name__c, (select Name, First_Name__c, Last_Name__c from Customers__r) from Employee__c limit 10];
return employee;
}
}
*******************************************************************************************
This is the Visualforce page code:
*******************************************************************************************
<apex:page controller="contrBinding" sidebar="false">
<apex:form >
<apex:pageBlock title="Employee Details">
<apex:pageBlockTable value="{!Empl}" var="emp">
<apex:column value="{!emp.Name}"/>
<apex:column value="{!emp.First_Name__c}"/>
<apex:column value="{!emp.Last_Name__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
*******************************************************************************************************
Can anyone tell me how can I bring the Customer recods on Visualforce page?
I say map because you already have a list of Employees and in order to capture the child records for each employee you need to query for the Employee Id on those records.
Also the map is useful to organize them by employee. this way you can have a list of Customers for each Employee in you "Empl" List
Once you have the Customers' map ready
in visual force you can grab the list of custmers by adding something like this
This will create a new Column with the information of all Customers related to that Employee
Im pretty sure you would like to organize it differently in the table but that would be up to you.
I Hope this helps