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
NishiNishi 

Inline editing in Visualforce page

Hi,

     Whenever a field has to be inline edited then the value gets saved only after clicking outside that area.Is this how the inline edit works in a visualforce page?

Best Answer chosen by Admin (Salesforce Developers) 
asish1989asish1989

Try this method

public PageReference saveMV(){
      if(mainViewRec.percent__c!=null){
         
          upsert mainViewRec;

         return null;
      }

}

All Answers

asish1989asish1989

NO you need to click on save button or enter for save.

 

for your reference go through this link

http://ap1.salesforce.com/help/doc/en/getstart_inline_editing.htm

NishiNishi
Hi Asish,
Sorry probably my query wasn't clear enough. The values get saved only after clicking outside and then clicking on save. After entering the value if the user doesn't click outside the inline edit area and directly clicks on save then the value isn't getting saved.
asish1989asish1989
You are facing same problem in custom visualforce page or standard detail page.If in vf page then share your code
NishiNishi

Yes the problem is in the visualforce page.Please find the code below

 

<apex:pageBlock id="pageblock1">
<apex:commandButton value="Save" id="saveButton" action="{!saveMV}" style="font-weight:bold" reRender="pageblock1"/>&nbsp;
<table><tr><td>
<apex:outputLabel value="Price Increase" style="font-weight:bold;"/></td>
<td style="background-color:#D0F5A9">
<apex:outputField value="{!mainViewRec.percent__c}" >
<img src="/s.gif" alt="Help" class="helpIcon" title="Double click to Edit the field."/>
<apex:inlineEditSupport event="ondblclick" />
</apex:outputField>
</td></tr></table>
</apex:pageBlock>

asish1989asish1989

 Actually I can't figure it out, Still try this, 

<apex:inlineEditSupport event="ondblClick"  showOnEdit="saveButton">

Let me know If it works otherwise share your controller method.

NishiNishi

It did not help. Please find the controller code below:

 

public class testController {

    public Main_View__c mainViewRec{get;set;}
    String currentAccountId;

    public testController(ApexPages.StandardController controller) {
    mainViewRec = new Main_View__c();
    currentAccountId = ApexPages.currentPage().getParameters().get('id');
     List<Main_View__c> lst = new List<Main_View__c>();
     lst = [Select Account__c,percent__c from Main_View__c where Account__c=:currentAccountId];
     if(lst!=null && lst.size()>0){
       mainViewRec = lst[0];
     }
}

    public void saveMV(){
      if(mainViewRec.percent__c!=null){
          mainViewRec.Account__c = currentAccountId;
          upsert mainViewRec;
      }
   }
}

asish1989asish1989

Try this method

public PageReference saveMV(){
      if(mainViewRec.percent__c!=null){
         
          upsert mainViewRec;

         return null;
      }

}

This was selected as the best answer
NishiNishi
Thank You,it worked.