Skip to main content
hi

how to show each contacts on the visualfroce page and each particular record have a button for edit and delete and save  ??

example

id ,lastName,firstName

112222xhd , xyz , yyy              edit ,delete,save

same another records .............. how to possible please suggest me

Thanks

Nagma

 
5 answers
  1. May 11, 2017, 7:10 AM
    Hi Nagma,

    Tyr this one

    VF Page:

    <apex:page standardController="Account" extensions="AccountListController" >

    <apex:form id="form">

    <apex:pageBlock title="Acconut List" id="account_list">

    <apex:pageBlockTable value="{!accList}" var="account" id="table">

    <apex:column headerValue="Action">

    <apex:commandLink value="Edit" reRender="account_list" rendered="{!account.id!=editList}">

    <apex:param assignTo="{!editList}" name="Edit"

    value="{!account.id}" />

    </apex:commandLink>

    <apex:commandLink value="Save" reRender="account_list" rendered="{!account.id==editList}" action="{!saveRecord}" />&nbsp;

    <apex:commandLink value="Del" reRender="table" rendered="{!account.id!=editList}" onclick="if (window.confirm('Are you sure?')) deleteAccount('{!account.Id}');"/>

    <apex:commandLink value="Cancel" reRender="account_list" rendered="{!account.id==editList}" action="{!cancelRecord}"/>

    </apex:column>

    <apex:column >

    <apex:facet name="header">Name</apex:facet>

    <apex:outputField value="{!account.Name}" rendered="{!account.id!=editList}" />

    <apex:inputField value="{!account.Name}" rendered="{!account.id==editList}" />

    </apex:column>

    <apex:column >

    <apex:facet name="header">Type</apex:facet>

    <apex:outputField value="{!account.Type}" rendered="{!account.id!=editList}" />

    <apex:inputField value="{!account.Type}" rendered="{!account.id==editList}" />

    </apex:column>

    <apex:column >

    <apex:facet name="header">Description</apex:facet>

    <apex:outputField value="{!account.Description}" rendered="{!account.id!=editList}" />

    <apex:inputField value="{!account.Description}" rendered="{!account.id==editList}" />

    </apex:column>

    </apex:pageBlockTable>

    </apex:pageBlock>

    <apex:actionFunction action="{!deleteAccount}" name="deleteAccount" reRender="table">

    <apex:param name="accountid" value="" assignTo="{!selectedAccountId}" />

    </apex:actionFunction>

    </apex:form>

    </apex:page>

    Class:

    Public class AccountListController{

    Public list<Account> accList{get;set;}

    Public Id editList{get;set;}

    Public String selectedAccountId{get;set;}

    Public list<Account> duelist{get;set;}

    Public list<Account> CandidateList{get;set;}

    Public AccountListController(ApexPages.StandardController controller){

    accList = new list<Account>();

    accList =[SELECT Id, Name, Type, Description FROM Account];

    }

    Public void saveRecord(){

    Update accList;

    editList = null;

    }

    Public void cancelRecord(){

    editList = null;

    }

    Public void deleteAccount(){

    if(selectedAccountId == Null){

    }

    else{

    Account ac=[select id from Account where id =:selectedAccountId];

    Delete Ac;

    editList = null;

    }

    }

    }

    Thanks,

    Ankur Saini

    http://mirketa.com
0/9000