You need to sign in to do that
Don't have an account?
URGENT:performing "save" action on custom object's vf page and doing pagination.
there is a vf page on custom object which shows all the contacts in the grid view.in the following format
Create New Contact(button) |
Action | Last Name | First Name | Phone | Account Name | |
Save | Editable data | Editable data | Editable data | Editable data | Editable lookup |
Save | Editable data | Editable data | Editable data | Editable data | Editable lookup |
what i need to do is:
1.on editing some field and then clicking save button...record should be saved and refreshes same page.
2. there is pagination required such only 20 records shown at a time and blow link to next page and previous page
2.a.there should not be previous on first page and next on last page.
i did like this...but both functionality are not working..please help
my vf page:-
<apex:page controller="ContactGrid" id="thepage" >
<apex:form id="theform" >
<apex:pageBlock title="Contact Grid" id="theblock" >
<apex:commandButton value="Create New Button"/>
<apex:pageBlockTable width="80%" columns="6" value="{!cppz}" var="o" id="thetable">
<apex:column headerValue="Action" >
<apex:commandButton value="Save" id="savebutton" action="{!saveContact}" rendered="{!Displayout == false}"/>
</apex:column>
<apex:column headerValue="Last Name" >
<apex:inputField value="{!o.LastName}" rendered="{!Displayout == false}"/>
</apex:column>
<apex:column headerValue="First Name" >
<apex:inputField value="{!o.FirstName}" rendered="{!Displayout == false}"/>
</apex:column>
<apex:column headerValue="Email" >
<apex:inputField value="{!o.Email}" rendered="{!Displayout == false}"/>
</apex:column>
<apex:column headerValue="Phone">
<apex:inputField value="{!o.Phone}" rendered="{!Displayout == false}"/>
</apex:column>
<apex:column headerValue="Account Name" >
<apex:inputField value="{!o.AccountId }" rendered="{!Displayout == false}"/>
</apex:column>
</apex:pageBlockTable>
<apex:outputPanel layout="block" styleClass="pSearchShowMore" id="otpNav2">
Total Records Found: <apex:outputText rendered="{!IF(Con.resultSize==20,true,false)}">20 +</apex:outputText><apex:outputText rendered="{!IF(Con.resultSize < 20,true,false)}">{!Con.resultSize}</apex:outputText>
<apex:image url="/img/search_prevarrow_disabled.gif" styleClass="prevArrow" rendered="{!NOT(Con.HasPrevious)}"/>
<apex:image url="/img/search_prevarrow.gif" title="Previous Page" styleClass="prevArrow" rendered="{!Con.HasPrevious}"/>
<apex:commandLink action="{!Previous}" title="Previous Page" value="Previous Page" rendered="{!Con.HasPrevious}"/>
<apex:outputPanel styleClass="pShowLess noLink" style="color:grey" rendered="{!NOT(Con.HasPrevious)}">Previous Page</apex:outputPanel>
({!IF(Con.PageNumber == 1,1,((Con.PageNumber -1) * Con.PageSize)+1)}-{!IF(Con.resultSize < Con.PageSize,Con.resultSize,Con.PageNumber * Con.pageSize)})
<apex:outputPanel styleClass="pShowLess noLink" style="color:grey" rendered="{!NOT(Con.HasNext)}">Next Page</apex:outputPanel>
<apex:commandLink title="Next Page" value="Next Page" rendered="{!Con.HasNext}" action="{!Next}"/>
<apex:image url="/img/search_nextarrow.gif" title="Next Page" styleClass="nextArrow" rendered="{!Con.HasNext}"/>
<apex:image url="/img/search_nextarrow_disabled.gif" rendered="{!NOT(Con.HasNext)}"/>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
controller class:-
public class ContactGrid
{
public Boolean Displayout{get;set;}
public ApexPages.StandardSetController con{get; set;}
public List<Contact> cppz;
public Id retid{get;set;}
public ContactGrid(){ }
public List<Contact> getCppz()
{
cppz=[Select c.Phone, c.LastName, c.FirstName, c.Email, c.AccountId From Contact c];
return cppz;
}
public pageReference saveContact()
{
upsert cppz;
Displayout = true;
return null;
}
//Boolean to check if there are more records after the present displaying records
public Boolean hasNext
{
get
{
return con.getHasNext();
}
set;
}
//Boolean to check if there are more records before the present displaying records
public Boolean hasPrevious
{
get
{
return con.getHasPrevious();
}
set;
}
//Page number of the current displaying records
public Integer pageNumber
{
get
{
return con.getPageNumber();
}
set;
}
//Returns the previous page of records
public void previous()
{
con.previous();
}
//Returns the next page of records
public void next()
{
con.next();
}
}