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
SabrentSabrent 

JAVA SCRIPT / JQuery - Allow users to Select some Checkboxes

I know this is achieveable through JAvascript / Jquery but don't know how?

 

On this visualfore page I have a table of records with a checkbox next to each record.

 

I want all users to see all records but only be able to select the records the user owns.

i.e/ 

IF(Userinfo.userid() != ownerid)

{

       disable checkbox;

} else {

 

      enable checkbox;

}

So if a user sees 5 records but owns only 3 of those records, Show all 5 records to the user but have the checkboxes for only 3 of the records enabled. Checkboxes on the other two records will be disabled.

 

 

<apex:page controller="MyAccountListCntrlr" tabStyle="Account">
   <apex:form >
      <apex:pageBlock title="Account List">
         <apex:pageBlockButtons >
            <apex:commandButton value="Show Selected Accounts" action="{!displaySelectedAccountNumbers}"/>
         </apex:pageBlockButtons>

         <!-- ACCOUNT LIST -->
         <apex:pageBlockTable value="{!acctList}" var="acctWrapper">
            <apex:column >
               <apex:inputCheckbox value="{!acctWrapper.isSelected}"/>
            </apex:column> 
            <apex:column value="{!acctWrapper.cAccount.AccountNumber}"/>
            <apex:column value="{!acctWrapper.cAccount.Name}"/>
         </apex:pageBlockTable>

         </apex:pageBlock>
   </apex:form>
</apex:page>

 

Best Answer chosen by Admin (Salesforce Developers) 
GSBassoGSBasso

Something like this might work:

 

 <apex:inputCheckbox value="{!acctWrapper.isSelected}" disabled="{!acctWrapper.cAccount.OwnerId != $User.Id}" />

 

All Answers

GSBassoGSBasso

Something like this might work:

 

 <apex:inputCheckbox value="{!acctWrapper.isSelected}" disabled="{!acctWrapper.cAccount.OwnerId != $User.Id}" />

 

This was selected as the best answer
SabrentSabrent
Thanks!!! I had tried the disabled tag but i guess i was not binding the variables correctly.

Much appreciated.