[SalesForce] how can I disable a checkbox on a visualforce page through conditions

                </apex:column>
                <apex:column headerValue="Grant" rendered="{!if(AND(wrp.oppContRole.contact.Portal_Access_Granted__c == null , wrp.oppContRole.contact.Portal_Access_Grant_Request__c == null),true,false)}">
                    <apex:inputCheckbox value="{!wrp.grant}" disabled="false"/>
                </apex:column>
                <apex:column headerValue="Grant" rendered="{!if(AND(wrp.oppContRole.contact.Portal_Access_Granted__c == null, wrp.oppContRole.contact.Portal_Access_Grant_Request__c == null),true,false)}">
                    <apex:inputCheckbox value="{!wrp.grant}" disabled="true"/>
                </apex:column>
                <apex:column headerValue="Revoke" rendered="{!if(AND(wrp.oppContRole.contact.Portal_Access_Revoked__c == null , wrp.oppContRole.contact.Portal_Access_Revoke_Request__c == null),true,false)}">
                    <apex:inputCheckbox value="{!wrp.revoke}" disabled="false"  onchange="var theTextBox = document.getElementById('{!$Component.check}'); theTextBox.disabled = theTextBox.disabled ? false : true;"/>
                </apex:column>
                <apex:column headerValue="Revoke" rendered="{!if(AND(wrp.oppContRole.contact.Portal_Access_Revoked__c == null , wrp.oppContRole.contact.Portal_Access_Revoke_Request__c == null),true,false)}">
                    <apex:inputCheckbox value="{!wrp.revoke}" disabled="true"  onchange="var theTextBox = document.getElementById('{!$Component.check}'); theTextBox.disabled = theTextBox.disabled ? false : true;"/>
                </apex:column>

If Portal_Access_Grant_Request__c(field in contact&& and working over opp.Contact Roles ) is filled in the appropriate contact then the checkbox(created by wrapper class and showen over vf) must be checked true and must be greyed out(read only)
and some more condition in vf

right now it showing two grant row as well as revoke bt i want one and c

Best Answer

You can't directly disable a checkbox in Visualforce using Apex. One is on the client-side, the other is on the server. As such, if you want them to interact, you have to send Visualforce the data it needs to make the decision to disable the checkbox. Here's a trivial example of this:

public class q192000 {
    // The wrapper class
    public class Wrapper {
        public Boolean checkbox1 { get; set; }
        public Boolean checkbox2 { get; set; }
        public Boolean checkbox2disabled { get; set; }
        public Wrapper() {
            checkbox1 = checkbox2 = checkbox2disabled = false;
        }
        // Called to update checkbox2's status
        public void updateStatus() {
            checkbox2disabled = checkbox1;
            if(checkbox1) {
                checkbox2 = true;
            }
        }
    }
    // Items to show on the page
    public Wrapper[] items { get; set; }
    // Page's initialization
    public q192000() {
        items = new Wrapper[0];
        for(Integer i = 0; i < 5; i++) {
            items.add(new Wrapper());
        }
    }
}

<apex:page controller="q192000">
    <apex:form id="form">
        <apex:pageBlock>
            <apex:pageBlockTable value="{!items}" var="item">
                <apex:column>
                    <apex:inputCheckbox value="{!item.checkbox1}">
                        <apex:actionSupport event="onchange" action="{!item.updateStatus}" reRender="form" />
                    </apex:inputCheckbox>
                </apex:column>
                <apex:column>
                    <apex:inputCheckbox value="{!item.checkbox2}" disabled="{!item.checkbox2disabled}" />
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Note that this page is kind of... well, slow. Visualforce wasn't really meant to do this sort of thing, so if you click really quickly, you might see some strange behavior. Nevertheless, this should cover the basics of what you're trying to accomplish.