function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
prasanth kumarprasanth kumar 

how to run action for specific commandbutton in apex:repeat itteration

i added command button for every coloum in apex:repeat, if i click on that button then it is invoking wrapper class and displaying the wrapper class rows to all records in apex:repeat ....  i want to only display the wrapper class rows for the specific row only (at which i clicked the button).  please help me. 

The below image is after i cliking on "Add Row" botton on 1st row
User-added image
<apex:page controller="createDynamicTableProcess" >
<apex:form >
<apex:pageblock title="All contacts" >
<apex:repeat value="{!cons}" var="a" >
<table border="1" width="300px;" > <tr> 
<td><apex:outputtext value="{!a.name}" /> <br/></td>
<td><apex:outputtext value="{!a.phone}" /><br/></td>
<td><apex:outputtext value="{!a.account.industry}" /><br/></td>
<td><apex:commandbutton value="Add Row" action="{!createRecordForSubContact}" >
<apex:param name="sending contact id" value="{!a.id}" assignto="{!contactid}" />
</apex:commandbutton>
<br/><br/></td>

</tr> </table> 
  <apex:pageblocktable value="{!scw}" var="a" id="pbt1">
            <apex:column ><apex:inputcheckbox value="{!a.flag}" /> </apex:column>
            <apex:column ><apex:inputtext value="{!a.name}" onchange="getrec(this.id)" id="v1"/> </apex:column>
            <apex:column ><apex:inputtext value="{!a.country}" onchange="getrec(this.id)" id="v2"/> </apex:column>
   </apex:pageblocktable>

</apex:repeat>
</apex:pageblock>
</apex:form>


</apex:page>
 
public class createDynamicTableProcess {

public list<contact> cons{set;get;}
public string contactid {set;get;}
public list<subcontactwrapper> scw{set;get;}
public createDynamicTableProcess ()
{
    cons=new list<contact>();

    list<string> accids=new list<string>();
        for(account a1:[select id from account])
            {
            accids.add(a1.id);
            }

       cons=[select id,name,phone,account.industry from contact where accountid in:accids limit 10];
} //constructor closed

//method for button click for every contact.
public void createRecordForSubContact()
{
scw=new list<subcontactwrapper>();
subcontactwrapper s1=new subcontactwrapper();
scw.add(s1);


}

public class subcontactwrapper
{
public boolean flag {set;get;}
public string name {set;get;}
public string country {Set;get;}
public date  startdate {Set;get;} 
}
}

 
Best Answer chosen by prasanth kumar
VinodKRVinodKR
Hi Prasanth,

You need to rerender the pageblocktable on click of commandbutton (i.e rerender="pbt1").

Thanks,

Have a great day ahead,Let the Force be with you!
Please mark this as best answer if it helps you.

All Answers

VinodKRVinodKR
Hi Prasanth,

You need to rerender the pageblocktable on click of commandbutton (i.e rerender="pbt1").

Thanks,

Have a great day ahead,Let the Force be with you!
Please mark this as best answer if it helps you.
This was selected as the best answer
prasanth kumarprasanth kumar
Love u @vinodkr