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
dmanidmani 

Disabling checkbox in Wrapper class

Hi,

 

I have a requirement to disable few lead records checkbox using wrapper class.

 

I have used disabled attribute to check some conditions and if the conditions returns true, it should disable the checkbox of tat particular lead records and remaining lead records should not be disabled.

 

Still i am not able to achieve it. Could some one help me.

 

class

public String UserRegion{get;set;}

currentUser = [select id,email,name,GCAM_Region__c from User where id =: userInfo.getUserId()];
         if(currentUser.GCAM_Region__c != null)
         {
         UserRegion = currentUser.GCAM_Region__c.substring(0,3);
         system.debug('XXX'+UserRegion );
         }

 

 

class LeadWrapper
    {
         public Boolean isSelected{get; set;}
         public Lead ld{get; set;}
         
         public LeadWrapper(Lead l,Boolean flag)
         {
              ld = l;
              isSelected = flag;
         }
    }
   

 

VF

<apex:pageBlockTable value="{!allLeads}" var="leadVar">
                                     <apex:column width="20px">
                                       <apex:facet name="header">
                                          <input type="checkbox" name="chk" id="chk" onclick='masterCheck(this.checked);'/>
                                       </apex:facet>
                                       <apex:inputCheckbox value="{!leadVar.isSelected}" onclick="childCheck(this.checked)" disabled="{IF(UserRegion!=leadVar.ld.LTC_Leads_Region_Name__r.Name,True,False)}" title="Please contact Retail Leads Team for Transfer of this Lead"/>
                                     </apex:column>

 

if the current user Region code is not matching with the leads Region Code, then the checkbox for that lead should be disabled.

 

Please help me to find out how to handle it if disabled attribute doesnt support.

 

simple-forcesimple-force

Hi,

 

Add to your wrapper class a additional boolean called "disabled". In your vf-page you can use the parameter "disabled" like <apex:inputCheckbox disabled="{!true}" /> to disable a specific checkbox.

 

In your controller you can check if a tick box should be disabled or not... 

 

 

Christian

Avidev9Avidev9

This should be easy one.

 

You generally access user details by doing $User in a VF page. So essentially your code should be 

<apex:inputCheckbox value="{!leadVar.isSelected}" onclick="childCheck(this.checked)" disabled="{IF($User.UserRegion!=leadVar.ld.LTC_Leads_Region_Name__r.Name,True,False)}"/>

 Just replace "UserRegion" with proper field api name