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
Shifs SalheenShifs Salheen 

Getting values from the datatable to controller

Hi ,
I have a data table in which one field which is checkbox is editable. But when I edit it,I am not able to get teh updated valeu in controller..Here is my code

VF Page
<apex:page sideBar="false" showHeader="false" controller="businessGoalList" standardStylesheets="false" docType="html-5.0" language="en-US" applyHTMLTag="false">
    <!-- Intro Section -->
  <!-- <apex:stylesheet value="{!URLFOR($Resource.Bootstrap_3_3_6, '/bootstrap-3.3.6-dist/css/bootstrap.min.css')}"/> 
    <apex:Stylesheet value="{!URLFOR($Resource.Bootstrap_3_3_6,'/bootstrap-3.3.6-dist/css/bootstrap.css')}"/> -->
   <script>
   function setSelectedContacts()
{
... code to visually highlight the rows and then call to actionFunction...

 apex_selectContacts();
}

   </script>
    <apex:composition template="indegeneTemplate">
         <apex:define name="body">
                <section id="intro" class="intro-section">
                    <div class="container" id= "mainDiv">
                 
                    <apex:form id="abc" >
                     
                  
                        <div class="row">
                        
                          
 
                            <div class="col-sm-12">
                                <div class="">
                                   
                                    <div class="row">
                                    
                                    
                                    <div class="panel panel-primary"> 

                                                <div class="panel-heading"> 
                                                    <h3 class="panel-title">Business Goals</h3> 
                                                </div> 
                                                <div class="panel-body"> 
                                   <apex:actionRegion >
                                    <apex:dataTable id="pgblock" value="{!listToBeDisplayeds}" var="bGoal"  styleClass="table">
                                 
                                         <apex:column >
                                             <apex:facet name="header" >  
                                               
                                               Business Goal
                                            </apex:facet> 
                                            
                                        <apex:outputText value="{! IF((bGoal.Value == null), 'NA', bGoal.Value) }"/>
                                  
                                         </apex:column>
                                        
                                        
                                          <apex:column >
                                             <apex:facet name="header" >  
                                               
                                              Response Variable
                                            </apex:facet> 
                                            <apex:outputText value="{! IF((bGoal.Label == null), 'NA', bGoal.Label) }"/>
                                         </apex:column>
                                          <apex:column >
                                             <apex:facet name="header" >  
                                           Inactive 
                                            </apex:facet> 
                                          <apex:inputCheckbox value="{!bGoal.Disabled}"  id="checkedone"  style="text-align:center">
                                            <apex:actionSupport event="onclick" action="{!CheckAll}"  reRender="none">
                                        <apex:param name="rowData" value="{!bGoal.Disabled}"/>
                                            </apex:actionSupport>
                                          </apex:inputCheckbox>



                                         </apex:column>
                                
                                
                                </apex:dataTable>
                                   <div class="col-md-10 col-md-offset-5">
                                    <apex:commandButton styleClass="btn btn-primary" value="Submit"  immediate="true"  reRender="out" action="{!saveBusinessGoals}"   />
 </div>
 </apex:actionRegion>
</div>
</div>
                                                        

                                    </div>   
                       <!-- <p><a class="btn btn-primary btn-lg page-scroll" href="http://uix.indegenexcloud.com/#header">Lets go!<div class="ripple-container"></div></a></p> -->
                    </div>
                </div>
            </div>
           
             
             
             
             
            </apex:form>
        </div>
        
        
       
        
     </section>
   </apex:define>
  </apex:composition>
  <style type="text/css">
        .custPopup {
    left: 30%;
    /* right: 25%; */
    padding: 10px;
    position: absolute;
    z-index: 9999;
    width: auto;
    height: auto;
    margin-left: 0px;
    scrollbar: yes;
    resizable: yes;
    top: 47%;
}        .buttonCss{
        text-align:center;
          width: 10%;
        }
        .popupBackground{
             background-color:rgba(0,0,0,0.4);             
                position: absolute;
                width: 100%;
                height: 100%;
                top: 0;
                left: 0;
                z-index: 9998;
        }
        
 </style>
</apex:page>


Controller
public class businessGoalList {

  


    public  List<SelectOption> listToBeDisplayeds { get; set; }

   

List<Business_Goal__c> allbusinessGoals  = new List<Business_Goal__c>();
List<Client_Business_Goal__c> clientBusinessGoals { get; set; }
Map<ID,String> mapOfClientBIdWithStatus = new Map<ID,String>();
 
    
    public String selectedCheckBox { get; set; }

 public businessGoalList() {
 System.debug('In constructor');
getMasterBusinessGoals();

   }

public List<SelectOption> getMasterBusinessGoals()
{
// Retrieve Client business Goals Status 

listToBeDisplayeds = new List<SelectOption>();

 clientBusinessGoals = [SELECT Business_Goal_Name__c,Business_Goal__c,Id,Name,Status__c FROM Client_Business_Goal__c];
if(clientBusinessGoals != null)
{
for(Client_Business_Goal__c cBGoal:clientBusinessGoals)
{
mapOfClientBIdWithStatus.put(cBGoal.Business_Goal__c,cBGoal.Status__c);
}
}


// retrieve All Master BusinessGoals
allbusinessGoals = new List<Business_Goal__c>();
 allbusinessGoals =  [SELECT Business_Goal_Code__c,Id,Name,Response_Variable__c,Status__c FROM Business_Goal__c ];
if(allbusinessGoals != null)
{
    
    for(Business_Goal__c bGoal : allbusinessGoals){
    System.debug('entruess'+bGoal);
    SelectOption selectOption = new SelectOption(bGoal.Name,bGoal.Response_Variable__c);
        if(mapOfClientBIdWithStatus != null && mapOfClientBIdWithStatus.containsKey(bGoal.Id))
        { 
            Boolean inActive = false;
           String status = mapOfClientBIdWithStatus.get(bGoal.Id);
          
          System.debug('Status:::'+status +'---'+bGoal.Id);
            if(status == 'Active'){
                inActive = false;
            }else
            {
                inActive = true;
            }
            selectOption.setDisabled(inActive);
            
            }else
            {
               selectOption.setDisabled(true);
            }
        listToBeDisplayeds.add(selectOption);
    }
}


return listToBeDisplayeds;
}

 public PageReference saveBusinessGoals() {
 System.debug('submiy business Goal::'+listToBeDisplayeds);
 
 
        return null;
    }


  public PageReference CheckAll() {
     String programId=System.currentPageReference().getParameters().get('rowData');
        System.debug('program ID::'+programId);
        return null;
    }

}

In saveBusinessGoals I am not getting the updated list instead m getting the list which comes on load