0

I am not able to navigate on next page in my pagination.here is my apex class

public ApexPages.StandardSetController setCon //pagignation for customer incident
{
    get{
        if(setcon==null)
        {
            size=10;
            string queryString = 'select id,Name,BMCServiceDesk__shortDescription__c,PHS_Category__c,PHS_Sub_Category__c,BMCServiceDesk__FKStatus__c from BMCServiceDesk__Incident__c where account__r.customerId__c=:currentSiteCust';
            setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
            setCon.setPageSize(size);
            noOfRecords = setCon.getResultSize();  
        }
        return setCon;
    }set;
}

public Boolean hasNext
{
    get {
        return setCon.getHasNext();
    }
    set;
}

public void first()
{
    setcon.first();
}

public void last()
{
    setcon.last();
}

public void previous()
{
    setcon.previous();
}

public void next()
{
    setcon.next();
} 

public pagereference searchincidents()//getting records from setcon
{   
    for(BMCServiceDesk__Incident__c  a : (List<BMCServiceDesk__Incident__c >)setCon.getRecords())
    {
        custincidentLst.add(a);
    }
    return null;
}

here is my vf page

<apex:pageblock id="pb">
    <apex:pageBlockTable value="{!custincidentLst}" var="inci">
    </apex:pageblockTable>
        <apex:column headerValue="Name">
            <apex:outputField value="{!inci.Name}"/>
        </apex:column> 
    </apex:pageblocktable>
    <apex:commandButton status="fetchStatus" reRender="pb" value="|<" action="{!first}" disabled="{!!setcon.hasPrevious}" title="First Page"/>
    <apex:commandButton status="fetchStatus" reRender="pb" value="<" action="{!previous}" disabled="{!!setcon.hasPrevious}" title="Previous Page"/>
    <apex:commandButton status="fetchStatus" reRender="pb" value=">" action="{!next}" disabled="{!!setcon.hasnext}" title="Next Page"/>
    <apex:commandButton status="fetchStatus" reRender="pb" value=">|" action="{!last}" disabled="{!!setcon.hasnext}" title="Last Page"/>
    <apex:outputText >{!(setCon.pageNumber * size)+1-size}-{!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,(setCon.pageNumber * size))} of {!noOfRecords}</apex:outputText>
    <apex:outputPanel style="color:#4AA02C;font-weight:bold">
        <apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/>
    </apex:outputPanel>
    </apex:pageblockgrid>
</apex:pageblock>
2
  • are you rerendering this PBT on any button click or just loading the data on page load? Commented Sep 19, 2016 at 9:15
  • yes, after clicking on a link i have to load these data. Commented Sep 19, 2016 at 9:18

1 Answer 1

1

Make this change: (You need to call getRecords() again and assign it to the list you are using on VF page... custincidentLst)

public void first()
{
    setcon.first();
custincidentLst= setCon.getRecords();
}

public void last()
{
    setcon.last();
custincidentLst= setCon.getRecords();
}

public void previous()
{
    setcon.previous();
custincidentLst= setCon.getRecords();
}

public void next()
{
    setcon.next();
custincidentLst= setCon.getRecords();
} 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .