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
Alex Valavanis 10Alex Valavanis 10 

Inline editing Visual force

Hello,

I created a visual force page (and a custom button) which updates the account ownership from a list view. I would like to add inline editing to the below. Could you please assist me?

<apex:page standardController="Account" recordSetVar="accounts" tabStyle="Account" sidebar="false" lightningStylesheets="true">
    <apex:form >
        <apex:pageBlock title="Edit Accounts" mode="edit">
            <apex:pageMessages />
            <apex:pageblockButtons location="top">
                <apex:commandButton value="Save" action="{!Save}" />
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
        <apex:pageBlockTable value="{!selected}" var="A">
            <apex:column headerValue="Name">
                <apex:outputField value="{!A.name}"/>
            </apex:column> 
            <apex:column headerValue="Owner">
                <apex:inputField value="{!A.OwnerId}"/>
            </apex:column>
       </apex:pageBlockTable>         
    </apex:pageBlock>
  </apex:form>
</apex:page>
Best Answer chosen by Alex Valavanis 10
Dushyant SonwarDushyant Sonwar
You can also try another example
<apex:page standardController="Account" recordSetVar="accounts" tabStyle="Account" sidebar="false" lightningStylesheets="true">
    <apex:form >
        <apex:pageBlock title="Edit Accounts" mode="edit">
            <apex:pageMessages />
            <apex:pageblockButtons location="top">
                <apex:commandButton value="Save" action="{!Save}" id="saveButton"/>
                <apex:commandButton value="Cancel" action="{!cancel}" id="cancelButton"/>
            </apex:pageBlockButtons>
        <apex:pageBlockTable value="{!accounts}" var="A">
            <apex:column headerValue="Name">
                <apex:outputField value="{!A.name}"/>
            </apex:column> 
            <apex:column headerValue="Owner">
                <apex:outputField value="{!A.OwnerId}"/>
            </apex:column>
            <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" />
       </apex:pageBlockTable>         
    </apex:pageBlock>
  </apex:form>
</apex:page>

 

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Alex,

>> https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_inline_editing.htm

The above link has an explanation of enabling inline editing in visualforce pages you can try checking it out!!

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
Dushyant SonwarDushyant Sonwar
Just add this InlineEditSupport tag in your page block table

Try this code snippet.
<apex:page standardController="Account" recordSetVar="accounts" tabStyle="Account" sidebar="false" lightningStylesheets="true">
    <apex:form >
        <apex:pageBlock title="Edit Accounts" mode="edit">
            <apex:pageMessages />
            <apex:pageblockButtons location="top">
                <apex:commandButton value="Save" action="{!Save}" id="saveButton"/>
                <apex:commandButton value="Cancel" action="{!cancel} id="cancelButton"/>
            </apex:pageBlockButtons>
        <apex:pageBlockTable value="{!selected}" var="A">
            <apex:column headerValue="Name">
                <apex:outputField value="{!A.name}"/>
            </apex:column> 
            <apex:column headerValue="Owner">
                <apex:inputField value="{!A.OwnerId}"/>
            </apex:column>
			<apex:inlineEditSupport event="ondblClick"
showOnEdit="saveButton,cancelButton"  />
       </apex:pageBlockTable>         
    </apex:pageBlock>
  </apex:form>
</apex:page>

Hope this helps!

 
Dushyant SonwarDushyant Sonwar
You can also try another example
<apex:page standardController="Account" recordSetVar="accounts" tabStyle="Account" sidebar="false" lightningStylesheets="true">
    <apex:form >
        <apex:pageBlock title="Edit Accounts" mode="edit">
            <apex:pageMessages />
            <apex:pageblockButtons location="top">
                <apex:commandButton value="Save" action="{!Save}" id="saveButton"/>
                <apex:commandButton value="Cancel" action="{!cancel}" id="cancelButton"/>
            </apex:pageBlockButtons>
        <apex:pageBlockTable value="{!accounts}" var="A">
            <apex:column headerValue="Name">
                <apex:outputField value="{!A.name}"/>
            </apex:column> 
            <apex:column headerValue="Owner">
                <apex:outputField value="{!A.OwnerId}"/>
            </apex:column>
            <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" />
       </apex:pageBlockTable>         
    </apex:pageBlock>
  </apex:form>
</apex:page>

 
This was selected as the best answer