• chris.wolf
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

I can't figure out how to save updated records back with a StandardSetController and an extension to paginate the (filtered) set of data.  I'm obviously missing the mechanism to get the filtered data set back to the standard set controller 'save' function, but I can't figure out how to add it.

 

VF page is:

 

<apex:page standardController="Orphan__c" extensions="OrphanBulkReportsWithPagination" recordSetVar="orphans">
    <apex:form >
        <apex:sectionHeader title="Bulk {!ReportType} Reports"/>
        <apex:pageBlock mode="edit">
            <apex:pageMessages />

            <apex:pageBlockSection title="Print {!ReportType}" collapsible="false">
                <apex:inputField value="{!Orphan__c.Biodata_Report_Sent__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Selected Orphans"  columns="1">
                <apex:pageblocktable value="{!PaginatedOrphans}" var="orphan" id="list">
                    <apex:column value="{!orphan.Name}"/>
                    <apex:column headerValue="Orphan Name">
                        <apex:outputText value="{!orphan.First_Name__c
                            & ' '
                            & orphan.Last_Name__c}"/>
                    </apex:column>
                    <apex:column value="{!orphan.Country__c}"/>
                    <apex:column value="{!orphan.IRP_Country__c}"/>
                    <apex:column headerValue="Biodata">
                        <apex:inputField value="{!orphan.Biodata_Report_Sent__c}"/>
                    </apex:column>
                </apex:pageblocktable>
            </apex:pageBlockSection>
            
            <apex:panelGrid columns="2">
                <apex:commandLink action="{!previous}">Previous</apex:commandlink>
                <apex:commandLink action="{!next}">Next</apex:commandlink>
            </apex:panelGrid>
            
            <apex:pageBlockButtons location="bottom">

                <apex:commandButton value="Save" action="{!saveOrphans}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

And controller extension is:-

 

public with sharing class OrphanBulkReportsWithPagination {

    Apexpages.StandardSetController controller;

    public OrphanBulkReportsWithPagination(ApexPages.StandardSetController c) {
        ReportType = ApexPages.currentPage().getParameters().get('rpt');
        Country = ApexPages.currentPage().getParameters().get('loc');
        controller = c;
    }    
    
    public ApexPages.StandardSetController orphanRecords {
        get {
            if(orphanRecords == null) {
                return new ApexPages.StandardSetController(
                         Database.getQueryLocator(
                [SELECT Id, name, First_Name__c, Last_Name__c, Country__c, IRP_Country__c, Biodata_Report_Sent__c FROM Orphan__c
                WHERE Biodata_Report_Sent__c = false
                And (Status__c = 'Available' OR Status__c = 'Sponsored')
                AND Id NOT IN (SELECT Orphan__c FROM Annual_Progress_Report__c where Sent_to_Donor__c = true)
                ]));
            }
            return orphanRecords;
        }
        private set;
    }

    public List<Orphan__c> getPaginatedOrphans() {
        return (List<Orphan__c>) orphanRecords.getRecords();
    }

}

 

Many thanks!