+ Start a Discussion
phanip adminphanip admin 

I have one scenario using VF Page please help any one

User should be able to view all the accounts (keep it to a limited number of records per page) in the organization as a list. The list should display few columns from the Account including sorting on columns Name, Phone and Type. List should contain additional column called Action where we have two actions Edit and Delete (links). Clicking on Edit link should render an Edit section below the Accounts list with few fields. User should be able change the values of the Account and save it. User should be provided two options Save and Cancel. Where Save will commit the changes to the database and the changes will be reflected on the list page along with hiding the Edit section. Cancel will not perform any changes to the record and hides the Edit section. When user clicks on Delete link the page should prompt the user with the confirmation. Once user confirms the record should be deleted from the database and the Account list should be refreshed.
ShirishaShirisha (Salesforce Developers) 
Hi Phanip,


You can create the Visualforce page and override it with the Accounts page or where exactly you wanted to display the account records.

Also,you will need to have the extension where you need to query the record or get the inputs from the VF page to insert the new accounts.

On the insert page,you can call the standard Save and Cancel buttons without any extra custom code.

Like wise,you can call the delete button to achieve your requirement.Here is the sample code in the below document which will help you further:


Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
phanip adminphanip admin
Hi Shirisha, 
Thanks for your respose
I am almost done, but still not yet completed the task in saving and cancel functionalities

Here is my code

//VF page

<apex:page controller="DataTableEditRemoveController" tabStyle="Product2">
<apex:form id="form" >
<apex:pageBlock title="Accounts">
  <!--<apex:pageMessages ></apex:pageMessages>-->
  <apex:pageBlockTable value="{!accs}" var="row">
     <apex:column value="{!row.Name}"/>
     <apex:column value="{!row.phone}"/>
     <apex:column value="{!row.type}"/>
      <apex:column >
       <apex:outputLink title="" value="/{!row.id}/e?retURL=/apex/{!$CurrentPage.Name}"
       <a href="javascript:if (window.confirm('Are you sure?')) DeleteAccount('{!row.Id}');" style="font-weight:bold">Del</a>
        <apex:pageBlockButtons >
    <apex:actionFunction action="{!DeleteAccount}" name="DeleteAccount" reRender="form" >
        <apex:param name="accountid" value="" assignTo="{!SelectedAccountId}"/>


//Apexclass : -

public class DataTableEditRemoveController {

   public List<Account> accs { get; set; }
   //used to get a hold of the account record selected for deletion
   public string SelectedAccountId { get; set; }
   public DataTableEditRemoveController() {
       //load account data into our DataTable
   private void LoadData() {
       accs = [Select id, name, phone, BillingCity, Type FROM Account limit 20];
   public void DeleteAccount()
      // if for any reason we are missing the reference 
      if (SelectedAccountId == null) {
      // find the account record within the collection
      Account tobeDeleted = null;
      for(Account a : accs)
       if (a.Id == SelectedAccountId) {
          tobeDeleted = a;
      //if account record found delete it
      if (tobeDeleted != null) {
       Delete tobeDeleted;
      //refresh the data