+ Start a Discussion
dax_traxdax_trax 

Need Radio button on a tabular data coming from List

I am a newbie for VF and APEX, I am trying to display a list of records in  apex datatable with a radio button, the radio buttons should be initially unchecked and only one radio button can be checked by the user, I need to grab the SF Id once user clicks on the radio button for a record, I have written a wrapper class to get the radio button with the list in VF, the problem is, my VF page loads with all the radio button selected.

 

 

Code for Wrapper Class:

 

public class Select_Wrapper {

public Orgs__c aum {get; set;}

        public Boolean selected {get; set;}

        

        public Select_Wrapper(Orgs__c nc){

            aum = nc;

            selected = false;

        }

 

Code For Controller :

 

public with sharing class abc {

public string msg{get;set;}

public string oid{get;set;}

public string compName{get;set;}

public string compDomain{get;set;}

public string ssId{get;set;}

public string Info{get;set;}

public integer updFlag = 0;

public integer recCount{get;set;}

public List<KOW> Selected_KOW;

public List<Orgs__c> InfgNCO = new List<Orgs__c>();

public List<Select_Wrapper> wrapPrd = New List<Select_Wrapper>();

    public abc(ApexPages.StandardSetController controller) {

     Selected_KOW = (List<KOW>) controller.getSelected();

       }

     

    public List<Select_Wrapper> Os(){

        if(wrapPrd == null){

            wrapPrd = new List<Select_Wrapper>();

        }            

            

     wrapPrd.clear();

     for(Orgs__c nc : [Select Name,Co_in__c,Co__c,ss_ID__c,Info__c From Orgs__c where something...]){

     Select_Wrapper objWrap = new Select_Wrapper(nc);

     wrapPrd.add(objWrap);

    

     }

        }

        return wrapPrd;

    }

    public Pagereference Finddata()

    {

     return null;

    }

    

}

 

VF Page:

 

<apex:page standardController="KOW"  recordSetVar="var2" extensions="abc">

<apex:form id="theForm">

...   

  <apex:outputPanel id="theResultPanel">

  <apex:actionStatus startText="(Fetching Data...)" stopText=" " id="searchStatus"/>

  <apex:pageBlock>

  <apex:dataTable value="{!Os}" var="var1" cellPadding="4" border="1" width="100%">

  <apex:column >

                    <apex:selectRadio value="{!var1.selected}"/>

                </apex:column>

  <apex:column >

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

  <apex:outputText value="{!var1.aum.Name}"/>

</apex:column>

  <apex:column >

  <apex:facet name="header">Cross Link</apex:facet>

<apex:outputText value="{!var1.aum.Co_in__c}"/>

</apex:column>

  <apex:column >

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

<apex:outputText value="{!var1.aum.Co__c}"/>

</apex:column>

  <apex:column >

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

<apex:outputText value="{!var1.aum.ss_ID__c}"/>

</apex:column>

  <apex:column >

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

<apex:outputText value="{!var1.aum.Info__c}"/>

</apex:column>

  </apex:dataTable>  

  </apex:pageBlock>

  </apex:outputPanel>

</apex:form>

</apex:page> 

 

Best Answer chosen by Admin (Salesforce Developers) 
ShikibuShikibu
Have a look at this post.

All Answers

ShikibuShikibu
Have a look at this post.
This was selected as the best answer
dax_traxdax_trax
Thanks a ton
Devendra@SFDCDevendra@SFDC

 

Hi dax_trax,

 

Can you please post your working code here?

 

I am having same problem. Hence it would be useful.

 

Regards,

Devendra S