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
MundMund 

HELP: URGENT Render / rerender in visualforce page having pageblocktable

Hello ,

 

Please help me with the code for the below page  Really in need of it.

I am having a pageblock table to display some information on the VF page. I need the rows that are being displayed in the pageblock table to be edited one by one on click of an edit button which will be available in each of the rows of the table

 

For example

Add row

office name    office address1  office state  

xyz                     address 1             state1                 del    edit

abc                    address 2            state 2                 del    edit

So on click of edit , that particular row has to be available for editing, (that is initially the values need to be set as non editable )

 

 The code what I have for displaying the page with Add  and delete link  is as below :

 

VF Page :

 

<apex:page controller="userMyInfoController" action="{!loadInfoDetails}" showHeader="false" sidebar="false" >

<apex:form >
<apex:outputLink value="{!$Site.Prefix}/secur/logout.jsp" rendered="{!NOT(ISPICKVAL($User.UserType,'Guest'))}">{!$Label.site.logout}</apex:outputLink>
<apex:pageBlock >
<apex:pageblock title="My Info">
<apex:pageblocksection title="Personal Details">
<apex:pageblocksectionitem >
    <apex:outputLabel for="txtUName">User Name</apex:outputLabel>
    <apex:inputText id="txtUName" value="{!objUser.Username}"/>
</apex:pageblocksectionitem>
<apex:pageblocksectionitem >
    <apex:outputLabel for="txtEmail">User Email</apex:outputLabel>
    <apex:inputText id="txtEmail" value="{!objUser.Email}"/>
</apex:pageblocksectionitem>
<apex:pageblocksectionitem >
    <apex:outputLabel for="txtLastName">Last Name</apex:outputLabel>
    <apex:inputText id="txtLastName" value="{!objUser.LastName}"/>
</apex:pageblocksectionitem>
</apex:pageblocksection>
<br> </br>

<apex:pageBlock mode="edit" title="Office Locations" id="OfficeLocations">

<!--Add more office locations-->
    <apex:commandLink value="Add Office Location" action="{!addOfficeLocation}"/> <br> </br>
    <apex:pageBlockTable columns="1" value="{!objOfficeLocations}" var="officeLoc" >
       <apex:column >
           <apex:outputLabel for="txtoffName"><b>Office Name</b></apex:outputLabel>&nbsp;
           <apex:inputText id="txtoffName" value="{!officeLoc.Office_Name__c}"/>
              
       </apex:column>
      
       <br> </br>
       <apex:column >
           <apex:outputLabel for="txtstate"><b>State</b></apex:outputLabel>&nbsp;
           <apex:inputText id="txtstate" value="{!officeLoc.Mailing_Address_State__c}"/>
       </apex:column>
       <apex:column >
           <apex:commandLink value="Delete" action="{!deleteOfficeLocation}" reRender="OfficeLocations">
                   <apex:param value="{!officeLoc.Office_Name__c}" name="delOfficeName"/>
            </apex:commandLink>
       </apex:column>
       <apex:column >
           <apex:commandLink value="Set as Primary" rendered="{!(NOT(officeLoc.Is_Office_Primary__c))}" action="{!changeOfficePrimary}"  >
               <apex:param value="{!officeLoc.Office_Name__c}" name="CurrentOfficeName"/>
            </apex:commandLink>
       </apex:column>
       </apex:pageBlockTable>
</apex:pageblock>

 

    </apex:pageblock>

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

</apex:page>

 

and in controller, i have the logic to add office location:

 

// Add more office locations
public void addOfficeLocation(){

    objOfficeLocations.add(new QUOD_Office_Location__c(User_ID__c=UserInfo.getUserId()));
   
}

public pageReference saveData(){
   
    upsert objOfficeLocations;
    
    //Delete office locations from the database
    if(toDelOfficeLocations.size() > 0)
    {
        delete toDelOfficeLocations;
    }

 

public pageReference deleteOfficeLocation(){
    string OfficeName = ApexPages.CurrentPage().getParameters().get('delOfficeName');
    for(Integer i = 0; i < objOfficeLocations.size(); i++)
    {
        if((objOfficeLocations[i].Office_Name__c == OfficeName) ) //|| (objOfficeLocations.get(i).get('id') == OfficeName.get('id'))
            {
                toDelOfficeLocations.add(objOfficeLocations.remove(i));
            }
    }
   
    return null;
}