You need to sign in to do that
Don't have an account?
Hildegard Olsen
Pagination not working on Visualforce page
Hi all!
Pagination not working on Visualforce page.
Can someone please help?
Thanks!
Pagination not working on Visualforce page.
Can someone please help?
Thanks!
<apex:page Controller="AccContact"> <apex:form > <apex:pageBlock mode="inlineEdit"> <apex:pageBlockButtons > <apex:commandbutton value="Save" action="{!save1}" /> <apex:commandbutton value="Cancel" action="{!cancel}" immediate="true"/> <apex:commandButton value="<<" rerender="details" action="{!beginning}" disabled="{!prev}"/> <apex:commandButton value="<" rerender="details" action="{!previous}" disabled="{!prev}"/> <apex:commandButton value=">" rerender="details" action="{!next}" disabled="{!nxt}"/> <apex:commandButton value=">>" rerender="details" action="{!end}" disabled="{!nxt}"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!acclst}" var="a"> <apex:column headerValue="Name"> <apex:commandLink action="{!selacc}"> <apex:param name="conlst" value="{!a.id}"/> <apex:outputText value="{!a.name}"/> </apex:commandlink> </apex:column> <!--accounts--> </apex:pageBlockTable> <apex:pageBlockTable value="{!accconts1}" var="a"> <apex:column headerValue="Account Name" value="{!a.Name}"/> <!--contacts--> <apex:column headerValue="List contacts"> <apex:pageBlockTable value="{!AccContacts}" var="c"> <apex:column headerValue="Title"> <apex:outputField value="{!c.title}"> <apex:inlineEditSupport event="ondblclick"/> </apex:outputField> </apex:column> <apex:column headerValue="First Name"> <apex:outputField value="{!c.firstname}"> <apex:inlineEditSupport event="ondblclick"/> </apex:outputField> </apex:column> <apex:column headerValue="Last Name"> <apex:outputField value="{!c.lastname}"> <apex:inlineEditSupport event="ondblclick"/> </apex:outputField> </apex:column> <apex:column headerValue="Email"> <apex:outputField value="{!c.email}"> <apex:inlineEditSupport event="ondblclick"/> </apex:outputField> </apex:column> <apex:column headerValue="Birthdate"> <apex:outputField value="{!c.birthdate}"> <apex:inlineEditSupport event="ondblclick"/> </apex:outputField> </apex:column> </apex:pageBlockTable> <!-- End contact--> </apex:column> </apex:pageBlockTable><!--end account--> </apex:pageBlock> </apex:form> </apex:page>
public with sharing class AccContact { private integer totalRecs = 0; private integer index = 0; private integer blockSize = 2; public list<contact> conlst { get; set; } public string getid {get; set;} public list<account> accconts1 { get; set; } public List<Account> acclst { get; set; } public AccContact (){ acclst=[select id,name from account ]; system.debug(acclst); conlst= getAccContacts(); totalRecs = [select count() from contact]; } public List<Contact> getAccContacts() { conlst=[select id,lastname,firstname,email,title,birthdate from contact where AccountId=: getId LIMIT :blockSize OFFSET :index ]; return conlst; } public PageReference selacc() { getid=apexpages.currentpage().getparameters().get('conlst'); accconts1=[select id,name,(select id,lastname,firstname,email,title,birthdate from contacts) from account where id=:getid ]; system.debug(accconts1); return null; } public void beginning() { index = 0; } public void previous() { index = index - blockSize; } public void next() { index = index + blockSize; } public void end() { index = totalrecs - math.mod(totalRecs,blockSize); } public boolean getprev() { if(index == 0) return true; else return false; } public boolean getnxt() { if((index + blockSize) > totalRecs) return true; else return false; } public PageReference save1() { update conlst; PageReference page = new Pagereference('/apex/Mass_Update'); page.setRedirect(true); return page; } public void cancel(){ PageReference page = new Pagereference('/apex/Mass_Update'); page.setRedirect(true); } }
Shruti S
Please elaborate your requirement. Sorry, I am having a tough time to make out from your code.