You need to sign in to do that
Don't have an account?
bhanu_prakash
Need to update and save child contact record from vf page with Pagination
Hi Team,
How can we update child record information from vf page and need to add pagination
controller :
It is fetching information of related contacts and unable to update save functionality .
How can we update child record information from vf page and need to add pagination
controller :
public with sharing class DiplayRelatedContacts { public List<Account> accList{get;set;} public list<Contact> conList{get;set;} public String accId{get;set;} public DiplayRelatedContacts(){ accList=[SELECT Id,Name,AccountNumber FROM Account LIMIT 10]; } public PageReference dispalyContact() { if(accId != null) conList=[SELECT id,FirstName,LastName,Phone,Department,Birthdate FROM COntact WHERE AccountId=:accId]; update conList; return null; } public pagereference save() { update accList; update conList; return null; } }Vf page
<apex:page controller="DiplayRelatedContacts" id="pg" lightningStylesheets="true"> <apex:form id="frm"> <apex:pageBlock id="pgblk" > <apex:pageBlockTable value="{!accList}" var="ac"> <apex:column width="10px"> <input type="radio" name="group1" /> <apex:actionSupport event="onclick" action="{!dispalyContact}" ReRender="conpgblk" > <apex:param assignTo="{!accId}" name="accname" value="{!ac.id}"/> </apex:actionSupport> </apex:column> <apex:column value="{!ac.Name}" /> <apex:column value="{!ac.AccountNumber}" /> </apex:pageBlockTable> </apex:pageBlock> <div id="globaSearch" class="modal fade" role="dialog" width="100%"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <!-- <button type="button" class="close" data-dismiss="modal">×</button> --> <h4 class="modal-title">Contacts</h4> </div> <div class="modal-body"> <apex:pageBlock id="conpgblk" > <apex:outputPanel rendered="{!conList.size == 0}"> <b> NO RELATED CONTACTS FOR THIS ACCOUNT .</b> </apex:outputPanel> <apex:outputPanel rendered="{!conList.size != 0}"> <apex:pageBlockTable value="{!conList}" var="con"> <apex:column value="{!con.FirstName}" /> <apex:column value="{!con.LastName}" /> <apex:column ><apex:facet name="header">Birthdate</apex:facet> <apex:inputField value="{!con.Birthdate}"/></apex:column> <apex:column ><apex:facet name="header">Department</apex:facet> <apex:inputField value="{!con.Department}"/></apex:column> <apex:column ><apex:facet name="header">Phone</apex:facet> <apex:inputField value="{!con.Phone}"/></apex:column> </apex:pageBlockTable> </apex:outputPanel> <apex:commandButton value="Save" id="save"/> </apex:pageBlock> </div> </div> </div> </div> </apex:form> </apex:page>
It is fetching information of related contacts and unable to update save functionality .
You have to pass a parameter to update the record using <apex:param> component of visualforce.
Try this code--
Mark this as best answer if this helps you.
Thanks
Sandeep