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
Soumya sri yaravaSoumya sri yarava 

how do i uncheck the selected values in wrapper class

public class test3{
 public list<string>listSelectedNames{get;set;}
 public list<Wrapperclass>wraplist{get;set;}
 public list<Wrapperclass> containslistcheck{get;set;}

  
  public test3(){
 listSelectedNames = new list<string>();
containslistcheck  = new list<Wrapperclass>(); 
 
 wraplist = new list<Wrapperclass>();
   Wrapperclass   wf = new Wrapperclass();
                  wf.selected=false;
                  wf.name ='Samsung';
                   wf.state='AndhraPradesh';
                 
    Wrapperclass   wf1 = new Wrapperclass();
                  wf1.selected=false;
                  wf1.name ='Oneplus';
                   wf1.state='Telangana';
                                  
   Wrapperclass   wf2 = new Wrapperclass();
                  wf2.selected=false;
                  wf2.name ='Lenovo';
                  wf2.state='Chennai';
                
     Wrapperclass   wf3= new Wrapperclass();
                  wf3.selected=false;
                   wf3.name ='Redmi';
                  wf3.state='AndhraPradesh';
                  
                  
                
                
          wraplist.add(wf);
          wraplist.add(wf1);
          wraplist.add(wf2);
          wraplist.add(wf3);
         
 }
 
 
   public void duplicatecheck(){
    listSelectedNames.clear();
   
    
    for(wrapperclass wrap: wraplist){
        if(wrap.selected == true){
           
            listSelectedNames.add(wrap.Name);
           
         }  
    }
    
    system.debug(listSelectedNames);
}


 //wrapper classs
    public class Wrapperclass{
       public boolean selected{get;set;}
       public string Name{get;set;}
        public string state{get;set;}
    }
  
  
}

v.f page:

 
<apex:page controller="test3">
   <apex:form >
   <apex:pageBlock >
      <apex:pageblockTable value="{!wraplist}"  var="a">
       <apex:column ><apex:inputCheckbox value="{!a.selected}"/>{!a.name}</apex:column>
        <apex:column >{!a.state}</apex:column>
       </apex:pageblockTable>
    <apex:commandButton value="OrderSelected"  reRender="one,two" action="{!duplicatecheck}"/>
       <apex:outputLabel id="two">{!listSelectedNames}</apex:outputLabel>
    </apex:pageBlock>
   </apex:form>
</apex:page>

User-added image


1)if i have selected the samsung checkbox with andhrapradesh, and 
2)if i select  the Redmicheckbox with andhrapradesh with  same state, it should show an alert and disable the Redmi checkbox, 

Please provide me help how can i achieve this, with links or solution s

Thanks and  Regards
 Soumya Reddy.
Thanks in advance
 
Abhishek BansalAbhishek Bansal
Hi Soumya,

You can call a javascript function onchange of the checkbox and in that javascript fucntion you can check whatever conditions you wnat to check. Based on your conditions you can show users the alert.
Also, you can disable the checkbox from the javasacript as well.
Let me know if you need any further help on this. You can also contact me on:
Gmail: abhibansal2790@gmail.com
Skype: abhishek.bansal2790
Mobile: 7357512102.

Thanks,
Abhishek Bansal.