Jul 5, 2024
77 Views
Comments Off on How to do Inline Edit in custom Salesforce Visualforce Page?
0 0

How to do Inline Edit in custom Salesforce Visualforce Page?

Written by

Hello guys,

We all know that we can edit the value of a field by going to the Edit Page, edit it and Save it using the Save button. But Salesforce also provides an effective way of editing the value of a field. We can use to edit content in field. To create that in our Custom Visualforce Pages we have to write code for that. Let see one example on INLINE EDIT

Visualforce Page :

<apex:page controller="InlineEditInVFController">
    <apex:form>
        <apex:pageBlock title="Account Information" >
            <apex:pageBlockTable value="{!acc}" var="a" title="Results" >
                <apex:inlineEditSupport showOnEdit="update, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"></apex:inlineEditSupport>
                <apex:column headerValue="Name">
                    <apex:outputfield value="{!a.name}"/>
                </apex:column>
                <apex:column headerValue="id">
                    <apex:outputfield value="{!a.id}"/>
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
        <apex:commandButton id="update" action="{!quickUpdat}"value="UpdateRecord"></apex:commandButton>
    </apex:form>
</apex:page>

Apex Class:

public class InlineEditInVFController {
    public List <Account> acc {get;set;}
    public InlineEditInVFController(){
        acc= Database.query('select Name,id from Account Limit 10');
    }
    public PageReference quickUpdat(){
        try{
            update acc;
            return ApexPages.CurrentPage();
        }
        catch(Exception e) {
            System.debub("@@@Error");
            return null;
        }
    }
}

Thanks.

Happy Coding.

Article Categories:
Blog
Priya Singh
https://thestarbiznews.com/

Expertise: Technology Trends, Startups, Digital Disruption Bio: Priya Singh is a tech-savvy millennial with a finger on the pulse of the ever-evolving digital landscape. A graduate of Stanford's Computer Science program and a former engineer at a Silicon Valley giant, Priya has a deep understanding of the technologies shaping our future. Her passion lies in demystifying complex tech jargon and exploring the disruptive potential of emerging trends, making her articles essential reading for anyone who wants to stay ahead of the curve. When not scouring the web for the latest tech tidbits, Priya enjoys traveling to off-the-beaten-path destinations and immersing herself in diverse cultures, always seeking new inspiration and insights.