You need to sign in to do that
Don't have an account?
Stéphane C.
Display on a Visualforce page object parent records with child object records
Hi,
I want to display on the same Visualforce page, the "Contact" records and the "Course" records.
I want to display on the same line the name of the student and the courses who is following. If the student is following several courses (n courses) so I want to display n lines (other ideas are welcome). I want to be able to inline edit the records.
I have create a controller :
And I have create a VisualForce page :
I cannot see how to make it works together.
Thank you.
I want to display on the same Visualforce page, the "Contact" records and the "Course" records.
I want to display on the same line the name of the student and the courses who is following. If the student is following several courses (n courses) so I want to display n lines (other ideas are welcome). I want to be able to inline edit the records.
I have create a controller :
public class inlineDetail { public List<contact> acclst=new List<contact>(); public List<contact> getContacts() { acclst=[select name,accountid,title,assistantphone,phone,(select name from courses__r) from contact]; return acclst; } public void saveChanges() { update acclst; } }
And I have create a VisualForce page :
<apex:page controller="inlineDetail"> <apex:form > <apex:pageBlock mode="inlineEdit"> <apex:pageBlockButtons > <apex:commandbutton value="save" action="{!saveChanges}"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!contacts}" var="c"> <apex:column Headervalue="Nom"> <apex:outputfield value="{!c.name}"/> </apex:column> <apex:column headervalue="Téléphone"> <apex:inputfield value="{!c.phone}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> <apex:relatedList list="Course__r"> <apex:facet name="header">Titles can be overriden with facets</apex:facet> </apex:relatedList> </apex:page>
I cannot see how to make it works together.
Thank you.
Any comments will be appreciated.
All Answers
May be you can try something like this.
I have a wlak around your code and I have some issues. And I don't know if it's me ?!
Perhaps we could work with a standard object like the opportunities.
So I want to list all the contact and I want to display if an opportunity is linked to a contact. An opportunity can have several contacts.
So I decide to rewrite my code to use the same format as your code :
Any idea what it is going wrong?
Thank you.
So, now I want to save the input data of the last column (like "Ok, it seems to work!"). It doesn't work because this is a child object records.
Is it possible? Any idea to do it?
Thank you.
Any comments will be appreciated.