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
prachi barahateprachi barahate 

inlineeditsupport with pageblocktable and standard list controller

I am writting a simple code in visualforce using standard list controller and inline edit support.Inline edit support is working properly .
But can able to save records.
Following is the code:
<apex:page standardController="Leave__c" recordSetVar="l">
<apex:form >
    <apex:pageBlock title="Display leaves records">
        <apex:pageBlockTable value="{!l}" var="e">
            <apex:column value="{!e.Employee__r.First_Name__c}"/>
            <apex:column value="{!e.From_Date__c}"/>
            <apex:column value="{!e.Leave_Type__c}"/>
            <apex:column value="{!e.To_Date__c}"/>   
            <apex:column value="{!e.Number_of_days__c}"/>   
            <apex:inlineEditSupport />                         
        </apex:pageBlockTable>  
  
         <apex:pageBlockButtons >
           <apex:commandButton value="Previous" action="{!previous}"/>
           <apex:commandButton value="Next" action="{!next}"/>
           <apex:commandButton value="first" action="{!first}"/>
           <apex:commandButton value="last" action="{!last}"/> <br/>       
           <apex:commandButton value="save" action="{!quickSave}"/>
        </apex:pageBlockButtons>
     </apex:pageBlock>   
</apex:form>
</apex:page>

M I missing something in this code.

Also when InlineditSupport is placed between column tags for every feild .Save is wroking fine.

But my confusion is why my above code is not working as i saw such type of codes working in many online tutorials examples.
 
Best Answer chosen by prachi barahate
Rahul_kumar123Rahul_kumar123
Hi Prachi,
  • The < apex:inlineEditSupport > component consist of an attribute called "
    Showonedit"  Please refer the code Below.
  • VisualForce Page
 
<apex:page standardController="Leave__c" extensions="RetrieveJobs">  
     <apex:form >  
    <apex:pageBlock mode="inlineEdit">  
            <apex:pageBlockButtons >  
               <apex:commandButton action="{!saveme}" id="saveButton" value="Save"/>  
               <apex:commandButton id="cancelButton" value="Cancel"/>  
        </apex:pageBlockButtons>  

    <apex:pageBlockTable value="{!lstJobs}" var="j">
        
        <apex:column headerValue="Days">
                <apex:actionRegion >
                      <apex:outputField value="{!j.From_Date__c }">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" />
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

            <apex:column headerValue="Start Date">
                <apex:actionRegion >
                      <apex:outputField value="{!j.Leave_Type__c}">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" />
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>
    </apex:pageBlockTable>
 </apex:pageBlock>  
</apex:form>  
</apex:page>
  • Apex Code:
public with sharing class RetrieveJobs {
  
    public List<Leave__c> lstJobs{get;set;}

    public RetrieveJobs(ApexPages.StandardController controller)
     {
               lstJobs = [Select Id, Name, From_Date__c,Leave_Type__c From Leave__c ];
    }

    public pagereference saveme()
    {
    try
    {
        update lstJobs;
    }   
    catch(Exception e)
    {
        System.debug('Exception occurred '+String.valueOf(e));
    }
    return NULL;
    }       
}
  • The output Screenshot

User-added image

I hope it will be helpful
  •  Please mark it as solved.so they removed from unanswered questions.and more appear as the proper solution to similar kind of issue. 

Best Regards
RahulKumar

All Answers

Rahul_kumar123Rahul_kumar123
Hi Prachi,
I think you Have missed out resetFunction="resetInlineEdit" in the following code.
 
<apex:inlineEditSupport  event="ondblclick" resetFunction="resetInlineEdit" />

Please check the below link which is earlier posted in success community for similar kind of issue.

http://success.salesforce.com/issues_view?id=a1p30000000Su1mAAC

I hope this could help you, please mark it as solved.
prachi barahateprachi barahate
I added this two attributes <apex:inlineEditSupport> .But its still not working.
One more thing ..is resetInlineEdit is a javascript function i have to write or is it a default function available.

sorry for asking very basic question.
Rahul_kumar123Rahul_kumar123
Hi Prachi,
  • The < apex:inlineEditSupport > component consist of an attribute called "
    Showonedit"  Please refer the code Below.
  • VisualForce Page
 
<apex:page standardController="Leave__c" extensions="RetrieveJobs">  
     <apex:form >  
    <apex:pageBlock mode="inlineEdit">  
            <apex:pageBlockButtons >  
               <apex:commandButton action="{!saveme}" id="saveButton" value="Save"/>  
               <apex:commandButton id="cancelButton" value="Cancel"/>  
        </apex:pageBlockButtons>  

    <apex:pageBlockTable value="{!lstJobs}" var="j">
        
        <apex:column headerValue="Days">
                <apex:actionRegion >
                      <apex:outputField value="{!j.From_Date__c }">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" />
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

            <apex:column headerValue="Start Date">
                <apex:actionRegion >
                      <apex:outputField value="{!j.Leave_Type__c}">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" />
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>
    </apex:pageBlockTable>
 </apex:pageBlock>  
</apex:form>  
</apex:page>
  • Apex Code:
public with sharing class RetrieveJobs {
  
    public List<Leave__c> lstJobs{get;set;}

    public RetrieveJobs(ApexPages.StandardController controller)
     {
               lstJobs = [Select Id, Name, From_Date__c,Leave_Type__c From Leave__c ];
    }

    public pagereference saveme()
    {
    try
    {
        update lstJobs;
    }   
    catch(Exception e)
    {
        System.debug('Exception occurred '+String.valueOf(e));
    }
    return NULL;
    }       
}
  • The output Screenshot

User-added image

I hope it will be helpful
  •  Please mark it as solved.so they removed from unanswered questions.and more appear as the proper solution to similar kind of issue. 

Best Regards
RahulKumar
This was selected as the best answer