0

This may be a easy question for some of you, I really hope so. I'm trying to get an "output Checkbox". I'm building a visualforce page and I need to expose check boxes results on that page. I tried the "outputField" but it doesn't show the tick box.

<apex:pageBlockSectionItem >
    <apex:outputLabel value="Custom Field" for="customField"/>
    <apex:outputField id="customField" value="{!Account.customField__c}"/>
</apex:pageBlockSectionItem>

On that code the CustomField__c is a tick box.

So, how can I accomplish this, because there is not an outputCheckBox and the inputCheckBox is not going to work either?

1
  • Please ignore this question. It is working correctly now. Commented Apr 11, 2014 at 13:38

5 Answers 5

5

According to my understanding, you want to display a checkbox with checked mark and it's a read only field. You can achieve that by doing like this:

<apex:inputcheckbox value="{!Account.customField__c}" label="Same as Above" selected="True" disabled ="true">

If it's not can you explain clearly what you want to display on vf page

2
  • Hi Kiran, thanks for your answer but it works fine with the outputField. I found an error on the check box field name, so that is why it was not showing up. Commented Apr 11, 2014 at 13:58
  • could you just post the error you are getting so that we can analysise the issue to get any solution
    – kiran
    Commented Apr 11, 2014 at 14:06
3

You could also do this:

            <apex:outputPanel rendered="{!r.isSuccess}" layout="block">
                <input type="checkbox" disabled="disabled" checked="checked"/>
            </apex:outputPanel>
            <apex:outputPanel rendered="{!NOT(r.isSuccess)}" layout="block">
                <input type="checkbox" disabled="disabled" />
            </apex:outputPanel>

Then you don't need an apex:form tag.

3

What about using the following code instead?

<apex:column headerValue="Custom Field">

<img src="/img/checkbox_{!IF(!Account.customField__c == TRUE, '', 'un')}checked.gif" />

</apex:column>
1
  • You can drop == TRUE. It will evaluate the same.
    – Adrian Larson
    Commented Jun 13, 2016 at 16:13
0

I believe I have a better answer.

<apex:inputcheckbox value="{!FieldName}"  onclick="return false" />

Instead of disabled = true. My solution doesn't render a greyed out checkbox, but when the user clicks nothing happens

2
  • It does force you to add an apex:form tag to the page though.
    – Adrian Larson
    Commented Apr 28, 2016 at 16:56
  • And unnecessary since output field works just fine :)
    – Eric
    Commented Apr 28, 2016 at 18:32
0

The <apex:outputField value="{!your Value}"/>shows the check box with tick mark. The other methods like <apex:inputcheckbox disabled=true> also work but I found this visually good.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .