I have simple custom page:
<apex:page controller="opportunityList2Con">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!employees}" var="o" >
<apex:column >
<apex:selectRadio value="{!o.Name}" label="Select"/>
</apex:column>
<apex:column value="{!o.Name}"/>
<apex:column value="{!o.Email__c}"/>
<apex:column value="{!o.Annual_salary__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:commandButton action="{!view}" value="View" id="theViewButton" />
<apex:commandButton action="{!edit}" value="Edit" id="theEditButton"/>
</apex:form>
</apex:page>
Unfortunately I am able to select more then one row in a list(so it behaves more like checkbox then radiobutton).
Do you know how can i resolve this problem?
Thanks
Best Answer
selectRadio renders a
List<SelectOption>
as a series of radio options. You cannot render the radio group across multiple rows. In terms of code, it is rendered as a table with one option in each cell; you can specify if the table goes across or down, but that table will be contained in a single row in the enclosing page block table (a single cell, in other words). To make a single selectable option out of a number of rows on a page block table, you'll need JavaScript or additional server-side code. You can find tons of examples of how to this with jQuery all over the web.