function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Semira@gmail.comSemira@gmail.com 

Refresh a field inside a pageblocktable

Hi I have a pageblocktable which displays a row of input fields, which could also consist of text and formula fields. My issue is that, I have a button call Save (quicksave), which saves the displayed record and their child record (rows displayed) without having to refresh the entire page. 

How do I refresh the value or get the value to populate when I click Save? It is calculating all the rollup summery fields but not the formula fields inside the pageblocktable.
 User-added image

The value only shows up if I hit Save and Close (redirects to the actual master record), then hit edit button again. 
<apex:page standardController="Budget__c"  extensions="BudgetController" standardStylesheets="true" >

    <apex:sectionHeader subtitle="{!Budget__c.Name}" title="Budget Form"/>

    <apex:form id="BudgetForm">
        <apex:pageMessages id="messages"/>
        <apex:pageBlock title="Budget Edit" mode="edit" id="BudgetpageBlock">
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!quickSaveBudget}" rerender="messages,BudgetForm, LineItem, test" />
                <apex:commandButton value="Save & Close" action="{!saveBudget}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
 <apex:actionRegion immediate="true">                  
                <apex:pageBlockSection title="Budget Line Item" >
                   
                    <apex:pageBlockTable value="{!wrapBudget}" var="wrap" id="LineItem">
                        <apex:column >
                            <apex:commandButton value="Delete" action="{!deleteLineItem}" reRender="LineItem">
                                <apex:param name="wrpIndxParam" value="{!wrap.indx}" assignTo="{!count}"/>
                            </apex:commandbutton>
                        </apex:column>
                        <apex:column headerValue="Trade">
                            <apex:inputField value="{!wrap.budget.Trade__c}"/>
                        </apex:column>
                        <apex:column headerValue="Revenue">
                            <apex:inputField value="{!wrap.budget.Revenue__c}"/>
                        </apex:column>
                        <apex:column headerValue="Allocations">
                        <apex:inputField value="{!wrap.budget.Allocations__c}"/>
                    </apex:column>

</apex:pageBlockTable>
</apex:pageBlockSection>
 </apex:actionRegion>

......................................................................

 </apex:pageBlock>
    </apex:form>
</apex:page>

Here is a snippet of what the visualforce looks like. Please let me know if this can be achievable. 

Thank you. 
Best Answer chosen by Semira@gmail.com
Prateek Singh SengarPrateek Singh Sengar
Hi Semira,
Your quickSaveBudget() method is calling saveLintItem() method however that saveLineItem is using wrapBudget list which is not getting repopulated. You need to call the method that populates wrapBudget so that re-render can display the value.

All Answers

Prateek Singh SengarPrateek Singh Sengar
Hi Semira,
Sure this can be achieved, However to pin point the exact changes we need to look at the apex class as well. In nutshell you need to repopulate the wrapBudget list on click of the save button. 
When the save button executes and your action "quickSaveBudget" is called you need to call the methods that populate the wrapBudget (which i assume is a list of wrapper class). 
Semira@gmail.comSemira@gmail.com
Hi thank you for your quick reply. I believe I am calling quickSaveBudget() is creating the wrapbudget inside the method QuickSave(). Here's the snippet of the code: 
public PageReference quickSaveBudget(){   
        try{
            ExtCon.save();
            saveLineItem(ExtCon.getID());
        }catch(Exception e){
            ApexPages.Message emsg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());    
            ApexPages.addMessage(emsg);
        }        
		
        return null;
    }
public void saveLineItem(ID budgetID){ 
  
        List<Budget_Line_Item__c> saveBudgetLineItem = new List<Budget_Line_Item__c>();

        for(WrapperClass wc:wrapBudget){
           if(wc.budget.Trade__c != null && wc.budget.Trade__c != ''){
                if(wc.budget.id==null){
                    wc.budget.Budget__c = budgetID;
                }

                saveBudgetLineItem.add(wc.budget);
            }

        }
  upsert saveBudgetLineItem;

 }

 public class WrapperClass{
        public Integer indx{get;set;}
        public Budget_Line_Item__c budget{get;set;}    
        public WrapperClass(Integer indx,Budget_Line_Item__c budget){
            this.indx = indx;
            this.budget = budget;
        }
    
    }

 
Prateek Singh SengarPrateek Singh Sengar
Hi Semira,
Your quickSaveBudget() method is calling saveLintItem() method however that saveLineItem is using wrapBudget list which is not getting repopulated. You need to call the method that populates wrapBudget so that re-render can display the value.
This was selected as the best answer
Jeevika SeenivasanJeevika Seenivasan
Hello, I have 3 page blog In a single page first page blog have records using checkbox .. If I checked one of the record... it rerender to pb3.. But the checked records in pb1 will be deleted after move to pb3... How do to do it... If knows