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
asd@as.asdasd@as.asd 

radio button in a table

hello

          i want to try somthing like this......

         Add a field ‘Primary Contact’ on Account, which would be a lookup to Contact object. Add a button on Account Detail      page labeled ‘Select Primary Contact’. On click of this button, a page should come up with list of all contacts associated with this Account in a table format. The left most column of this table would be a radio button. User should be able to select one contact and submit this page. On submission, the selected contact would become Primary Contact for this account and user would be redirected back to Account detail page.

 

      here i face a problem to create a table with selectradio button

 

IspitaIspita

Hi ,

What is the issue with that , you can use the HTML input component for that as below:-

<input type="radio" name="color" id="{con.id}" value="{con.id}"> 

the above code will assign dynamic  ids to the radio buttons when used within any iterations.

 

Hope this helps...

asd@as.asdasd@as.asd

thanks for reply 

   but i want use <apex:selectradio> button          here is my code using  <input type="radio"> and this is working 

 

page

 

<apex:page standardController="Account" extensions="RadioButton" showheader="false">
<apex:form >
<apex:pageblock id="allcons" title="Available Contacts">
<apex:pageblocktable id="allcons" value="{!AllContacts}" var="allcon">

<apex:column headervalue="Set as Primary">
<apex:actionSupport action="{!selectcon}" event="onclick" reRender="hidden">
<input type="radio" name = "selectedContact">
<apex:param name="conid" value="{!allcon.Id}"/ >
</input>
</apex:actionSupport>
</apex:column>

<apex:column headervalue="Last Name">
<apex:outputfield value="{!allcon.LastName}"/>
</apex:column>

<apex:column headervalue="First Name">
<apex:outputfield value="{!allcon.FirstName}"/>
</apex:column>

<apex:column headervalue="Email">
<apex:outputfield value="{!allcon.Email}"/>
</apex:column>

<apex:column headervalue="Phone">
<apex:outputfield value="{!allcon.Phone}"/>
</apex:column>

</apex:pageblocktable>

<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!save}" value="Save" />
<apex:commandButton action="{!back}" value="Cancel"/>
</apex:pageBlockButtons>

</apex:pageblock>

<apex:pageBlock id="hidden" rendered="false"></apex:pageBlock>

</apex:form>
</apex:page>
                             
comtroller
public class RadioButton {

    public RadioButton(ApexPages.StandardController controller) {

    }


public Contact con;
public Account acc;
public String selcontactid;
Public List<contact> getAllContacts()
{
acc = [select id,primary_contact__c from account where id = :Apexpages.currentPage().getParameters().get('id')];
List<contact> allcons = [Select Id,FirstName,LastName,Email,Phone from Contact where accountId = :Apexpages.currentPage().getParameters().get('id')];
return allcons;
}

Public void selectCon()
{
selcontactid = System.currentPagereference().getParameters().get('conid');
}

public pageReference save(){
acc.primary_contact__c = selcontactid ;
update acc;
return back();

}

Pramodh KumarPramodh Kumar
Hi,

Did you find any solution for the <apex:selectRadio> tag, I have similar kind of scenario.
If i use selectRadio tag, the radio button are moving to the next row referred in the figure.

User-added image
Here is my code.
<apex:selectRadio value="{!survey__c.Sales__c}">
     <tr>      
             <td>
                    {!$ObjectType.survey__c.fields.pramodht__Sales__c.label}
             </td>
             <td>
                     <apex:selectOption itemValue="Poor"/>
             </td>
             <td>
                  <apex:selectOption itemValue="Average"/> 
             </td>
             <td>
                 <apex:selectOption itemValue="Good"/> 
             </td>
       </tr>
</apex:selectRadio>

Please let me know if you have any solution or any idea.


Thanks,
pRAMODH.