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
mauricio.ramosmauricio.ramos 

Update fields in pageblocktable when data changes

I havea  pageblocktable in a VF page that contains a list of Sales Order Items which among other fields contain a lookup to product(<apex:inputField value="{!SOI.ProductId__c}" />). I want to be able to update the fields in that row when I change the product in the lookup field. I only want to rerender that row and not the entire table. Below is the code I was able to put together, can anyone assist:

 

VF page code:

 

<apex:actionFunction status="outStatus" name="reload" rerender="SOIList" />
    <apex:pageblock title="Sales Order Items"  tabStyle="SCRB_SalesOrder__c" >
    <apex:pageBlockButtons >
       <apex:commandButton action="{!AddSOI}" value="Add New Item" rerender="SOIList" />
    </apex:pageBlockButtons>
    <apex:pageMessages /> 
     <apex:outputPanel >
     <apex:actionRegion id="table">
            <apex:pageblockTable value="{!SOItems}" var="SOI" id="SOIList" >
                <apex:column headerValue="Action">
                    <apex:commandLink value="Del" action="{!del}" rerender="SOIList" style="font-weight:bold"  >&nbsp;|&nbsp;
                        <apex:param name="delname" value="{!SOI.id}" assignTo="{!currSOIid}"/>
                        <apex:outputLink title="" value="/{!SOI.id}" style="font-weight:bold" target="_blank" >View</apex:outputLink>
                    </apex:commandLink>
                </apex:column>
                
                <apex:column headerValue="Line type">
                    <apex:inputField value="{!SOI.Line_Type__c}" />
                </apex:column>
                
                <apex:column headerValue="Product">
                    <apex:inputField value="{!SOI.ProductId__c}" />
                </apex:column>
                
                <apex:column headerValue="Description">
                    <apex:inputField value="{!SOI.Description__c}" />
                </apex:column>
                <apex:column headerValue="Quantity">
                    <apex:inputField value="{!SOI.Quantity__c}" />
                </apex:column>
                
                <apex:column headerValue="Unit Cost" >
                    <apex:outputField value="{!SOI.Unit_Cost__c}" />
                </apex:column>
                <apex:column headerValue="Sales Price ex VAT">
                    <apex:inputField value="{!SOI.SalesPrice__c}" />
                </apex:column>
                <apex:column headerValue="Line Disc Pct.">
                    <apex:inputField value="{!SOI.Line_Discount_Pct__c}" />
                </apex:column>
                <apex:column headerValue="Line Disc Amt.">
                    <apex:inputField value="{!SOI.Line_Discount_Amount__c}" />
                </apex:column>
                <apex:column headerValue="Total Price">
                    <apex:inputField value="{!SOI.TotalPrice__c}" />
                </apex:column>
                <apex:column headerValue="Line Status">
                    <apex:inputField value="{!SOI.Line_Status__c }" />
                </apex:column>  
            </apex:pageBlockTable>
        </apex:actionRegion>
        </apex:outputPanel>
            <apex:actionregion >
            
            <apex:pageBlockSection title="Sale Order Item Detail" columns="2" collapsible="true" id="SOIs" showHeader="true" >
            
            </apex:pageBlockSection>
            </apex:actionregion>
    </apex:pageblock>

 Thanks!!

Best Answer chosen by Admin (Salesforce Developers) 
mauricio.ramosmauricio.ramos

I have gone with the approach to add a command link beside the Product Lookup since that component does have support for javascript events although it is not the cleanest and most user friendly solution, it works.

 

Thanks!!!

All Answers

SRKSRK

I am not sure that u can pass a murge field in rerender just try it if it's possible then i solve our problem

in u r
<apex:inputField value="{!SOI.ProductId__c}" /> just add on change event

sample code

<apex:actionfunction action ="{!test}"name="chanlookupfield" id="chanlookupfield" rerender ="{!rerendercolid}"/>

<apex:inputField value="{!SOI.ProductId__c}" Onchange ="show"/>

 

<script>

   chanlookupfield();

</script>

 

Class

public void test()

{

   rerendercolid = 'COL 1, COL 2'; // ASSING THEALL THE COLUMS id CORRESPONDING TO THE LOOK UP FIELD WHICH IS    CHANGE

}

mauricio.ramosmauricio.ramos

I have gone with the approach to add a command link beside the Product Lookup since that component does have support for javascript events although it is not the cleanest and most user friendly solution, it works.

 

Thanks!!!

This was selected as the best answer