0

we are having an issue here related to select radio. We have a radio button which has potentially up to 5 options, but only the first 2 are showing up.

Here is the Visualforce page code:

<apex:outputPanel id="RadioPanel" layout="Block" rendered="{!ParentController.ParentController.IdToIndicatorResponse[ObjectID].Question_Type__c == 'True/False'|| ParentController.ParentController.IdToIndicatorResponse[ObjectID].Question_Type__c == 'Select One'}">
            <apex:selectRadio value="{!ParentController.ParentController.IDToRoleToSingleResponse[ObjectID][UserRoleName]}" layout="pageDirection" disabled="{!IsDisabled}"
                              style="font-size:100%">

                <apex:selectOption itemValue="{!ParentController.ParentController.IdToIndicatorResponse[ObjectID].Option_1__c}" itemLabel="{!ParentController.ParentController.IdToIndicatorResponse[ObjectID].Option_1__c}" rendered="{!IF(ParentController.ParentController.IdToIndicatorResponse[ObjectID].Indicator__r.Use_Option_1__c = true, true, false)}"/>
                <apex:selectOption itemValue="{!ParentController.ParentController.IdToIndicatorResponse[ObjectID].Option_2__c}" itemLabel="{!ParentController.ParentController.IdToIndicatorResponse[ObjectID].Option_2__c}" rendered="{!IF(ParentController.ParentController.IdToIndicatorResponse[ObjectID].Indicator__r.Use_Option_2__c = true, true, false)}"/>
                <apex:selectOption itemValue="{!ParentController.ParentController.IdToIndicatorResponse[ObjectID].Option_3__c}" itemLabel="{!ParentController.ParentController.IdToIndicatorResponse[ObjectID].Option_3__c}" rendered="{!IF(ParentController.ParentController.IdToIndicatorResponse[ObjectID].Indicator__r.Use_Option_3__c = true, true, false)}"/>
                <apex:selectOption itemValue="{!ParentController.ParentController.IdToIndicatorResponse[ObjectID].Option_4__c}" itemLabel="{!ParentController.ParentController.IdToIndicatorResponse[ObjectID].Option_4__c}" rendered="{!IF(ParentController.ParentController.IdToIndicatorResponse[ObjectID].Indicator__r.Use_Option_4__c = true, true, false)}"/>
                <apex:selectOption itemValue="{!ParentController.ParentController.IdToIndicatorResponse[ObjectID].Option_5__c}" itemLabel="{!ParentController.ParentController.IdToIndicatorResponse[ObjectID].Option_5__c}" rendered="{!IF(ParentController.ParentController.IdToIndicatorResponse[ObjectID].Indicator__r.Use_Option_5__c = true, true, false)}"/>
            </apex:selectRadio>
            <apex:outputText value="Using q 1"  rendered="{!IF(ParentController.ParentController.IdToIndicatorResponse[ObjectID].Indicator__r.Use_Option_1__c = true, true, false)}"/>
             <apex:outputText value="Using q 2"  rendered="{!IF(ParentController.ParentController.IdToIndicatorResponse[ObjectID].Indicator__r.Use_Option_2__c = true, true, false)}"/>
             <apex:outputText value="Using q 3"  rendered="{!IF(ParentController.ParentController.IdToIndicatorResponse[ObjectID].Indicator__r.Use_Option_3__c = true, true, false)}"/>
             <apex:outputText value="Using q 4"  rendered="{!IF(ParentController.ParentController.IdToIndicatorResponse[ObjectID].Indicator__r.Use_Option_4__c = true, true, false)}"/>
             <apex:outputText value="Using q 5"  rendered="{!IF(ParentController.ParentController.IdToIndicatorResponse[ObjectID].Indicator__r.Use_Option_5__c = true, true, false)}"/>
        </apex:outputPanel>

The output text conditionally displays corresponding to the rendered condition, but the radio options do not follow the same.

We know it is possible to have more than two radio buttons show up. When we use this, it works.

<apex:selectRadio value="{!ParentController.ParentController.IdToIndicatorResponse[ObjectID][StatusFieldName]}" layout="pageDirection" disabled="{!IsDisabled}" style="font-size:100%">
            <apex:selectOption itemValue="Met" itemLabel="Met"/>
            <apex:selectOption itemValue="Partially Met" itemLabel="Partially Met"/>
            <apex:selectOption itemValue="Has Not Met" itemLabel="Has Not Met"/>
        </apex:selectRadio>

Any ideas about how to get these conditionally rendered radio options working?

Thanks

1

the best way to render which values to show on the page is by handling the logic in the controller

Visual Force code:

    <apex:selectRadio value="{!radioSelect}" >
<apex:selectOptions value="{!radioSelectList}"/>
</apex:selectRadio>

apex code:

 public list<SelectOption> getradioSelectList(){
     list<SelectOption> options = new list<SelectOption>();
IF(ParentController.ParentController.IdToIndicatorResponse[ObjectID].Indicator__r.Use_Option_1__c)
    {
    options.add(new SelectOption(ParentController.ParentController.IdToIndicatorResponse[ObjectID].Indicator__r.Use_Option_1__c, ParentController.ParentController.IdToIndicatorResponse[ObjectID].Option_1__c));
    }
return options;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.