0

I have one custom object budget which has lookup to opportunity.I have added a list button on Budget related list.Onclick of that button I am trying to open a VF page that will edit all budget records.I have passed standard set controller.But I am not getting all the records in stanadard set controller.I have 36 records but just getting 20 records in set controller.Can somebody solve my issue orelse I will have to pass Opportunity Id to my query to fetch those Budget records.

VF page

<apex:page standardController="Budget__c" extensions = "CtrlEditAllBudget" docType="html-5.0" recordsetVar = "budgetRecords"> 
display records from wrapper
</apex:page>

public with sharing class CtrlEditAllBudget {
    public Integer Year{get;set;}
    private ApexPages.StandardSetController stdSetController;

    public List<Budget__c> lstBudget;
    public List<BudgetWrapper> lstBudgetWrapper {get;set;}

    public CtrlEditAllBudget(ApexPages.StandardSetController stdSetController){

        this.stdSetController = stdSetController;
        system.debug('stdSetController=>'+stdSetController.getRecords());
        List<Budget__c> budidlist = (List<Budget__c>)stdSetController.getRecords();

        for(Budget__c budinstance:budidlist){
            system.debug('budget id = >'+budinstance.Id);
        }



        system.debug('stdSetController size=>'+stdSetController.getRecords().size());
        Year = Date.Today().Year();
        //lstBudget = [SELECT Id,Opportunity__c,Month__c,Year__c,Type__c,Amount__c FROM Budget__c WHERE Id IN:stdSetController.getRecords()];
        lstBudget = [SELECT Id,Opportunity__c,Month__c,Year__c,Type__c,Amount__c FROM Budget__c WHERE Opportunity__c IN:stdSetController.getRecords()];
        system.debug('lstBudget=>'+lstBudget);
        system.debug('lstBudget size =>'+lstBudget.size());

        lstBudgetWrapper = new List<BudgetWrapper>();
        for(Budget__c budgetInstance:lstBudget){

            if(budgetInstance.Type__c.equals('Services')){
                BudgetWrapper budgetWrap = new BudgetWrapper();
                budgetWrap.Amount1 = budgetInstance.Amount__c;
                budgetWrap.monthString = budgetInstance.Month__c;
                lstBudgetWrapper.add(budgetWrap);
            }
            if(budgetInstance.Type__c.equals('Engineering')){
                BudgetWrapper budgetWrap = new BudgetWrapper();
                //lstBudgetWrapper.add(new BudgetWrapper(Amount1 = budgetInstance.Amount__c,monthString = budgetInstance.Month__c));
                budgetWrap.Amount2 = budgetInstance.Amount__c;
                budgetWrap.monthString = budgetInstance.Month__c;
                lstBudgetWrapper.add(budgetWrap);
            }
            if(budgetInstance.Type__c.equals('Infrastucture')){
                BudgetWrapper budgetWrap = new BudgetWrapper();
                //lstBudgetWrapper.add(new BudgetWrapper(Amount1 = budgetInstance.Amount__c,monthString = budgetInstance.Month__c));
                budgetWrap.Amount3 = budgetInstance.Amount__c;
                budgetWrap.monthString = budgetInstance.Month__c;
                lstBudgetWrapper.add(budgetWrap);
            }   
        }

        system.debug('lstBudgetWrapper size=>'+lstBudgetWrapper.size());
        system.debug('lstBudgetWrapper =>'+lstBudgetWrapper);   
    }

     public class BudgetWrapper{

        public String monthString {get;set;}
        public BudgetWrapper() { 
            Amount1 = 0;
            Amount2 = 0;
            Amount3 = 0;
            monthString = '';
        }

        public decimal Amount1{get;set;}
        public decimal Amount2{get;set;}
        public decimal Amount3{get;set;}
    }


}

1 Answer 1

1

Set page size in constructor:

    public CtrlEditAllBudget(ApexPages.StandardSetController stdSetController)
    {
       // Set Page Size
       stdSetController.setPageSize(50);
       this.stdSetController = stdSetController;
       system.debug('stdSetController=>'+stdSetController.getRecords());
       List<Budget__c> budidlist = (List<Budget__c>)stdSetController.getRecords();

       for(Budget__c budinstance:budidlist)
       {
         system.debug('budget id = >'+budinstance.Id);
       }
    }
0

You must log in to answer this question.

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