You need to sign in to do that
Don't have an account?
hisrinu
How to display Parent to Child Relationship in VF?
How to display the contact Name in VF page.
Below is the example, I want to display Contact Name in VF_Page.
Any Suggestions.
Below is the example, I want to display Contact Name in VF_Page.
Any Suggestions.
Code:
<apex:page controller="Relationships"> <apex:dataTable value="{!Accounts}" var="a"> <apex:column headervalue="Name" value="{!a.Id}"/> <apex:column headervalue="Name" value="{!a.Contact.Name}"/> </apex:dataTable> </apex:page> public class Relationships { public List<Account> getAccounts() { List<Account> AL = new List<Account>(); AL = [SELECT Id, (SELECT Name FROM Contacts WHERE Name != '') FROM Account]; return AL; } }
Hi.. Srini..
Try this
Thanks for your reply. I know that but It will display in two tables but I want to display them in only one table.
Because the inner query will be in a list format so we need to display as separate table but is there any other way.
Here is an example of a nested query result dispaly using pageblock and the repeat tag that might help you get started.
Thanks for your reply, I know that if we fetch from contact it will be easier.
But my actual requirement is I have to fetch from Account, Contact and Opportunity
That is the reason I am trying in this manner.
What is your desired hierarchy?
Are you looking for this:
Account
-Contact
-Contact
-Contact
--Opportunity
--Opportunity
--Opportunity
Any restrictions? Like do you not want accounts that don't have both contacts and opportunities? Some other conditions?
One consideration we haven't discussed is how many results you expect to have. Lists won't handle over 1000 results, and this would show a pretty large page result anyway.