You need to sign in to do that
Don't have an account?
Desai
Next and Previous buttons in a VF page
Hi,
We have a VF page which displays the list of quotes based on the status. This part is working as expected but we need to add nex and previous buttons in the VF page. How do we do it.
VF page :
<apex:page StandardController="Quote" extensions="QuotePgeCtrl" sidebar="true" tabStyle="HPQuotes__tab" recordSetvar="quoteList">
<html>
<div class="blank"> </div>
<div class="content"><img src="/s.gif" class="pageTitleIcon" title="Quote"/>
<h1>Quotes</h1><br>
<font size="5">Home</font></br>
<div class="blank"> </div>
</div></html>
<apex:form >
<apex:pageBlock title="Recent Quotes">
<b>View: </b>
<apex:selectList size="1" value="{!quotevalue}">
<apex:actionSupport event="onchange" action="{!getreviewdqt}" rerender="table1"/>
<apex:selectOption itemLabel="None" itemValue="None"></apex:selectOption>
<apex:selectOption itemLabel="Draft Quotes" itemValue="Draft Quotes"></apex:selectOption>
<apex:selectOption itemLabel="Accepted Quotes" itemValue="Accepted Quotes"></apex:selectOption>
<apex:selectOption itemLabel="Review Pending Quotes" itemValue="Review Pending Quotes"></apex:selectOption>
</apex:selectList>
<div style="width:100%; margin-top:5px;height:450px; overflow:scroll;">
<apex:pageBlockTable id="table1" value="{!quoteList}" var="quotes" >
<apex:column >
<apex:facet name="header">Name</apex:facet>
<a href="#" onClick="window.parent.location.href='/{!quotes.Id}'">{!quotes.Name}</a>
</apex:column>
<apex:column >
<apex:facet name="header">Quote Number</apex:facet>
<a href="#" onClick="window.parent.location.href='/{!quotes.Id}'">{!quotes.QuoteNumber}</a>
</apex:column>
<apex:column >
<apex:facet name="header">Account Name</apex:facet>
<a href="#" onClick="window.parent.location.href='/{!quotes.Opportunity.Account.Id}'">{!quotes.Opportunity.Account.name}</a>
</apex:column>
<apex:column >
<apex:facet name="header">Opportunity Name</apex:facet>
<a href="#" onClick="window.parent.location.href='/{!quotes.Opportunity.Id}'">{!quotes.Opportunity.name}</a>
</apex:column>
<apex:column >
<apex:facet name="header">Status</apex:facet>
{!quotes.Status}
</apex:column>
<apex:column >
<apex:facet name="header">Expiration Date</apex:facet>
<apex:outputText value="{0,date,MM/dd/yyyy}">
<apex:param value="{!quotes.ExpirationDate}"/>
</apex:outputText>
</apex:column>
<apex:column ><apex:facet name="header">Grand Total</apex:facet>
<apex:outputText value="{0, number, currency}">
<apex:param value="{!quotes.GrandTotal}"/>
</apex:outputText>
</apex:column>
</apex:pageBlockTable>
</div>
<apex:panelGrid columns="2">
<apex:commandLink action="{!previous}">Previous</apex:commandlink>
<apex:commandLink action="{!next}">Next</apex:commandlink>
</apex:panelGrid>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex class:
public class QuotePgeCtrl
{
public QuotePgeCtrl(ApexPages.StandardSetController controller) {
}
public Id quoteId {get;set;}
public QuotePgeCtrl(ApexPages.StandardController controller)
{
sObject quote = controller.getRecord();
quoteId = (Id) quote.get('Id');
}
public string quotevalue{get; set;}
public list<Quote> quoteList{get; set;}
public list<Quote> getreviewdqt()
{
if(quotevalue == 'None')
{
quoteList= new list<Quote>([SELECT Opportunity.Account.Name, QuoteNumber, GrandTotal, Opportunity.name,OpportunityId, Name, IsSyncing, Id, Status,ExpirationDate From Quote WHERE Status ='None' ]);
//ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(quoteList);
}
if(quotevalue == 'Draft Quotes')
{
quoteList= new list<Quote>([SELECT Opportunity.Account.Name, QuoteNumber, GrandTotal, Opportunity.name,OpportunityId, Name, IsSyncing, Id, Status,ExpirationDate From Quote WHERE Status ='Draft' LIMIT 10 OFFSET 10]);
//ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(quoteList);
}
if(quotevalue == 'Accepted Quotes')
{
quoteList= new list<Quote>([SELECT Opportunity.Account.Name, QuoteNumber, GrandTotal, Opportunity.name,OpportunityId, Name, IsSyncing, Id, Status,ExpirationDate From Quote WHERE Status ='Accepted']);
// ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(quoteList);
}
if(quotevalue == 'Review Pending Quotes')
{
quoteList= new list<Quote>([SELECT Opportunity.Account.Name, QuoteNumber, GrandTotal, Opportunity.name,OpportunityId, Name, IsSyncing, Id, Status,ExpirationDate From Quote WHERE Status ='Review Pending']);
// ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(quoteList);
}
return null;
}
}
Thanks.
We have a VF page which displays the list of quotes based on the status. This part is working as expected but we need to add nex and previous buttons in the VF page. How do we do it.
VF page :
<apex:page StandardController="Quote" extensions="QuotePgeCtrl" sidebar="true" tabStyle="HPQuotes__tab" recordSetvar="quoteList">
<html>
<div class="blank"> </div>
<div class="content"><img src="/s.gif" class="pageTitleIcon" title="Quote"/>
<h1>Quotes</h1><br>
<font size="5">Home</font></br>
<div class="blank"> </div>
</div></html>
<apex:form >
<apex:pageBlock title="Recent Quotes">
<b>View: </b>
<apex:selectList size="1" value="{!quotevalue}">
<apex:actionSupport event="onchange" action="{!getreviewdqt}" rerender="table1"/>
<apex:selectOption itemLabel="None" itemValue="None"></apex:selectOption>
<apex:selectOption itemLabel="Draft Quotes" itemValue="Draft Quotes"></apex:selectOption>
<apex:selectOption itemLabel="Accepted Quotes" itemValue="Accepted Quotes"></apex:selectOption>
<apex:selectOption itemLabel="Review Pending Quotes" itemValue="Review Pending Quotes"></apex:selectOption>
</apex:selectList>
<div style="width:100%; margin-top:5px;height:450px; overflow:scroll;">
<apex:pageBlockTable id="table1" value="{!quoteList}" var="quotes" >
<apex:column >
<apex:facet name="header">Name</apex:facet>
<a href="#" onClick="window.parent.location.href='/{!quotes.Id}'">{!quotes.Name}</a>
</apex:column>
<apex:column >
<apex:facet name="header">Quote Number</apex:facet>
<a href="#" onClick="window.parent.location.href='/{!quotes.Id}'">{!quotes.QuoteNumber}</a>
</apex:column>
<apex:column >
<apex:facet name="header">Account Name</apex:facet>
<a href="#" onClick="window.parent.location.href='/{!quotes.Opportunity.Account.Id}'">{!quotes.Opportunity.Account.name}</a>
</apex:column>
<apex:column >
<apex:facet name="header">Opportunity Name</apex:facet>
<a href="#" onClick="window.parent.location.href='/{!quotes.Opportunity.Id}'">{!quotes.Opportunity.name}</a>
</apex:column>
<apex:column >
<apex:facet name="header">Status</apex:facet>
{!quotes.Status}
</apex:column>
<apex:column >
<apex:facet name="header">Expiration Date</apex:facet>
<apex:outputText value="{0,date,MM/dd/yyyy}">
<apex:param value="{!quotes.ExpirationDate}"/>
</apex:outputText>
</apex:column>
<apex:column ><apex:facet name="header">Grand Total</apex:facet>
<apex:outputText value="{0, number, currency}">
<apex:param value="{!quotes.GrandTotal}"/>
</apex:outputText>
</apex:column>
</apex:pageBlockTable>
</div>
<apex:panelGrid columns="2">
<apex:commandLink action="{!previous}">Previous</apex:commandlink>
<apex:commandLink action="{!next}">Next</apex:commandlink>
</apex:panelGrid>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex class:
public class QuotePgeCtrl
{
public QuotePgeCtrl(ApexPages.StandardSetController controller) {
}
public Id quoteId {get;set;}
public QuotePgeCtrl(ApexPages.StandardController controller)
{
sObject quote = controller.getRecord();
quoteId = (Id) quote.get('Id');
}
public string quotevalue{get; set;}
public list<Quote> quoteList{get; set;}
public list<Quote> getreviewdqt()
{
if(quotevalue == 'None')
{
quoteList= new list<Quote>([SELECT Opportunity.Account.Name, QuoteNumber, GrandTotal, Opportunity.name,OpportunityId, Name, IsSyncing, Id, Status,ExpirationDate From Quote WHERE Status ='None' ]);
//ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(quoteList);
}
if(quotevalue == 'Draft Quotes')
{
quoteList= new list<Quote>([SELECT Opportunity.Account.Name, QuoteNumber, GrandTotal, Opportunity.name,OpportunityId, Name, IsSyncing, Id, Status,ExpirationDate From Quote WHERE Status ='Draft' LIMIT 10 OFFSET 10]);
//ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(quoteList);
}
if(quotevalue == 'Accepted Quotes')
{
quoteList= new list<Quote>([SELECT Opportunity.Account.Name, QuoteNumber, GrandTotal, Opportunity.name,OpportunityId, Name, IsSyncing, Id, Status,ExpirationDate From Quote WHERE Status ='Accepted']);
// ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(quoteList);
}
if(quotevalue == 'Review Pending Quotes')
{
quoteList= new list<Quote>([SELECT Opportunity.Account.Name, QuoteNumber, GrandTotal, Opportunity.name,OpportunityId, Name, IsSyncing, Id, Status,ExpirationDate From Quote WHERE Status ='Review Pending']);
// ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(quoteList);
}
return null;
}
}
Thanks.
Instead of
<apex:commandLink action="{!previous}">Previous</apex:commandlink>
<apex:commandLink action="{!next}">Next</apex:commandlink>
these lines in your VF code add,
<apex:commandButton action="{!previous}" value="Previous"/>
<apex:commandButton action="{!next}" value="Next"/>
Please check it. If its not working let me know.
Thanks & Regards,
SAGA BJ
Issue is still the same, next set of records is not shown. On Click on Next button, the VF page still shows the same set of records.
Thanks.
Actually am not getting it. It will be good if you post the screenshots. As a last try in
quoteList= new list<Quote>([SELECT Opportunity.Account.Name, QuoteNumber, GrandTotal, Opportunity.name,OpportunityId, Name, IsSyncing, Id, Status,ExpirationDate From Quote WHERE Status ='Draft' LIMIT 10 OFFSET 10]);
remove the limit 10 offset 10
and add
controller.setPagesize(15);
this line. As like
public QuotePgeCtrl(ApexPages.StandardController controller)
{
controller.setPagesize(15);
sObject quote = controller.getRecord();
quoteId = (Id) quote.get('Id');
}
If this is also please post the screenshots, i will try entire code and reply you
Thanks & Regards,
SAGA BJ