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
awilawil 

repeat within selectRadio

I want to use a radioselect in a table with many rows, configured like this:

 

 radioselect example

 

The blank cells to the right of each radiobutton will contain text corresponding to the radiobutton (a label of sorts). I want to use a table primarily because some rows will have the radiobuttons hidden/not-rendered and I want everything to remain lined up.

 

Here is how I tried to code it up:

 

 

<apex:selectRadio value="{!mergeLineItem.name}" rendered="{!mergeLineItem.rendered}">
<apex:repeat value="{!mergeLine.mergeLineItems}" var="mergeLineItem">
<td class="white" align="center">
<apex:SelectOption value="{!mergeLineItem.option}"/>
</td>
<td class="white">{!mergeLineItem.value}</td>
</apex:repeat>
</apex:selectRadio>

 

But that creates some malformed HTML:

 

<td align="right" class="yellow">Record</td>
<td align="center" class="white">
</td>
<td class="white"></td><table>
<tr>
<td>
<input type="radio" checked="checked" name="j_id0:j_id3:j_id4:j_id15:0:j_id17:0:j_id18" id="j_id0:j_id3:j_id4:j_id15:0:j_id17:0:j_id18:0" value="record__c" /><label for="j_id0:j_id3:j_id4:j_id15:0:j_id17:0:j_id18:0"> </label></td>
</tr>
</table>


<td align="center" class="white">
</td>
<td class="white"></td><table>
<tr>
<td>
<input type="radio" checked="checked" name="j_id0:j_id3:j_id4:j_id15:0:j_id17:1:j_id18" id="j_id0:j_id3:j_id4:j_id15:0:j_id17:1:j_id18:0" value="record__c" /><label for="j_id0:j_id3:j_id4:j_id15:0:j_id17:1:j_id18:0"> </label></td>
</tr>
</table>

<td align="center" class="white">
</td>

<td class="white">No</td><table>
<tr>
<td>
<input type="radio" checked="checked" name="j_id0:j_id3:j_id4:j_id15:0:j_id17:2:j_id18" id="j_id0:j_id3:j_id4:j_id15:0:j_id17:2:j_id18:0" value="record__c" /><label for="j_id0:j_id3:j_id4:j_id15:0:j_id17:2:j_id18:0"> </label></td>
</tr>
</table>

 I've highlighted the part that causes trouble. It looks like each instance of SelectOption ends up rendering a complete table of its own, but only after closing the TD tag that I was trying to put the radiobutton in. The end result is completely screwed up table HTML that doesn't render at all.

 

1. Is this a VF bug?

 

2. How can I accomplish what I want to display, namely displaying radiobuttons that aren't all right next to each other and (in my case) are in every other cell of a table, so that I can put some text in the cell to the right of each radiobutton?

 

 

 

 

 

 

 

 

SteveBowerSteveBower

I haven't tried this, and I'm not certain this is the right approach, but an idea that occurs to me is that instead of putting your own TD tags in and trying to make a table out of it, could you instead just use the standard sort of :

<apex:selectRadio value="{!country}">
<apex:selectOptions value="{!items}"/>
</apex:selectRadio><p/>

 straight out of the documentation and start playing around with the .css in order to change the layout?  Perhaps use display:inline?

 

It just seems to me that CSS is the better way to tackle it.  Random thought.  Best, Steve.

 

 

 

Message Edited by SteveBower on 03-13-2009 11:55 AM
shimritshimrit

Hi awil,

 

I'm facing with exactly the same problem you mentioned above.

 

How did you manage to solve this issue? please advise.

 

Many thanks, Shimrit