3

I am trying to do something same to Contact Role in Opportunity related list. For this i need to add a radio button on this, i have a wrapper class which is used to display on VF page how can i get it add to radio button on wrapper class and how to get whether which buttion is selected.

1

This blog post explains the concept of a Wrapper Class. You don't have to do anything special to get the select value, as it will be bound to the controller when the page is submitted.

I'd still render them as checkboxes, to make the checkboxes appear as Radio Buttons, you're best applying a css style.

To make it behave like the Standard Opportunity Contact Role Edit Page, you'd have to write some onChange javascript which automatically unchecks all of the other checkboxes, when one of them is selected.

1

If by radio button you mean that only one should be selected, or some other simple logic have to be implemented, a common way to proceed is to use jQuery.

Every checbkox (styled as radio button if you wish) will have an id="cbox_{!wrapper.index}" an onclick="singleSelect('cbox_{!wrapper.index}')" and finally styleClass="myChecks"

in the head of your visualforce page you will have:

<apex:includeScript value="{!URLFOR($Resource.jquery)}"/>
<script type="text/javascript">
    j$ = jQuery.noConflict();

    function singleSelect(ele){
         //remove all checks
         j$('.myChecks').removeAttr("checked");
         //add the check to the selected checkbox
         j$('#'+ele).attr("checked", "checked");
    }
</script>

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.