I have created a table with edit option.Whenever clicking the particular row edit link the whole table rows enabled to edited. but i want to edit a particular row.


public class account2task1

public string id;
public Boolean bool {get;set;}
public Boolean bool1 {get;set;}
public List<account> contt{get;set;}
public Integer counterNumber{ get; set; }
    public account2task1(ApexPages.StandardController controller) {
    bool = true;

     contt=[select id,name,accountnumber,phone from account limit 5];

public void save2() {

    bool =false;



VF page:

<apex:page standardController="account" extensions="account2task1" showHeader="false" sidebar="false">
    <apex:form > 

        <apex:pageBlock >

     <apex:pageBlockSection >
     <apex:dataTable value="{!contt}"   var="a" cellpadding="4" border="1" width="100">
                 <apex:column headervalue="Action">
                 <apex:commandLink value="Edit"  action="{!save2}"  >


           <apex:column headervalue="Account name" width="50"  >
           <apex:inputField value="{!a.name}" html-disabled="{!bool}" id="a1" />
           <script>document.getElementById('{!$Component.a1}').disabled = {!bool}; </script> </apex:column> 

                 <apex:column headervalue="Account number" width="50" >
                <apex:inputField value="{!a.accountnumber}" html-disabled="{!bool}" id="a2" />
                <script>document.getElementById('{!$Component.a2}').disabled = {!bool}; </script> </apex:column> 




  • 3
    Is this you? Did you create a new username to post another question? Why not just stay under the same name? salesforce.stackexchange.com/questions/87664/… – Eric Aug 11 '15 at 4:45
  • mahi did'not understand your code please revise this code and put revised code of class – Ravi Vadher Aug 11 '15 at 4:46
  • The best way to do it, IMO is to put a wrapper class around your data so you can bind buttons directly to those rows. – dphil Aug 11 '15 at 16:46

This should be fairly easy to do with standard Visualforce. See the example below. You may have to adapt it as per your use case and refine it a bit.


public class AccountController {

    public List<Account> accountList{get; set;}
    public Id editId {get; set;}

    public AccountController(ApexPages.StandardController controller) {
        accountList = [select id,name,billingcity,Phone,Website from Account limit 20];

    public void saveRecord(){
        update accountList;
        editId = null;


 <apex:page standardController="Account" extensions="AccountController">    
<apex:pageBlock id="pbId">
    <apex:pageBlockTable value="{!accountList}" var="acc">          
            <apex:commandButton value="Edit" reRender="pbId" rendered="{!acc.id!=editId}">
                <apex:param assignTo="{!editId}" name="edit" value="{!acc.id}"/>

            <apex:commandButton value="Save" reRender="pbId" rendered="{!acc.id==editId}" action="{!saveRecord}">
            <apex:facet name="header">Account Name</apex:facet>
            <apex:outputField value="{!acc.name}" rendered="{!acc.id!=editId}"/>
            <apex:inputField value="{!acc.name}" rendered="{!acc.id==editId}"/>
            <apex:facet name="header">City</apex:facet>
            <apex:outputField value="{!acc.BillingCity}" rendered="{!acc.id!=editId}"/>
            <apex:inputField value="{!acc.BillingCity}" rendered="{!acc.id==editId}"/>                


So what I am doing is I remember what row I clicked edit on by saving it in a variable, and I rerender the table. When the table variable iterates, I check whether this one was selected for editing, and if it is then I render the inputfield, or else the outputfield.

Not the answer you're looking for? Browse other questions tagged or ask your own question.