How-to-edit-visualforce-page

How to do Inline Edit in custom Salesforce Visualforce Page?

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 a 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.

0 Comments

Leave a Reply

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2019 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?