Skip to main content
Tom Nguyen (Candela Corporation) ha fatto una domanda in #Apex
I'm using apex:repeat to display a list of input checkboxes.  The first time the page load, the checkboxes are display correctly.  Once one of the checkbox is checked then I would make an Ajax call to reevaluate the list and rerender it again, but the rerender is not working.  At the moment, there are 3 checkboxes loaded.  Once one of them is checked then it should only display 1.  Right now it is displaying 3 after the ajax calls. I also look at the debug log and it is adding to the wrapper class correctly with 1 record but it is displaying it correctly. Can someone point me in the right direction?  Thanks.  

VF

<div class="row" id="vendor">

                    <div class="col-md-12 col-sm-6" style="font-size:12px;padding-left: 50px!important;padding-bottom: 20px!important">

              

                        <apex:outputPanel id="VendorRefresh2">

                        <apex:outputPanel id="VendorRefresh" style="font-size:13px;background-color:⌗C41130!important;" styleClass="label label-primary">Vendor</apex:outputPanel><br/>

                            

                        <div class="divscroll">

                           

                                  <apex:repeat value="{!VendorGroup}" var="v">

                                      <apex:inputCheckbox value="{!v.vendorSelected}">

                                   

                                           <apex:actionSupport action="{!getVendorSelected}" status="myStatus" reRender="ajaxrequest,VendorRefresh2" event="onclick"/>

                                              

                                      </apex:inputCheckbox> <a href=""> {!v.acc['name']}</a> ({!v.acc['pg']})

                                      <br/>

                                    </apex:repeat>

                            

                            </div>

                       </apex:outputPanel>

                    </div>

                </div>

Apex:

public class vendorWrapper{

        public AggregateResult acc{get;set;}       

        public Boolean vendorSelected {get;set;}

        public vendorWrapper(AggregateResult a, boolean bSelected){

            acc = a;            

            vendorSelected = false;

        }

    }

public list<vendorWrapper> getVendorGroup(){

        system.debug('Build VendorGroup');

           String sFilters = '';

        sFilters = Filters();

        vendorWrap.clear();

       

    

            for(AggregateResult a: database.query('SELECT primary_vendor__r.id id, primary_vendor__r.name name, count(id) pg FROM Product2 where ' + sFilters + ' and primary_vendor__r.name <> null group by primary_vendor__r.id, primary_vendor__r.name order by primary_vendor__r.name')){     

                

                if (sVendorIds != ''){

                    vendorWrap.add(new vendorWrapper(a, true));

                    system.debug(sVendorIds + ' checked');

                }else{

                    vendorWrap.add(new vendorWrapper(a, false));

                    system.debug(sVendorIds + ' not checked');

                }

            }  

     

        system.debug('getVendorGroup vendorWrapSize: ' + vendorWrap.size());

        return vendorWrap;

      

    }

public PageReference getVendorSelected(){

           sVendorIds = '';

         setVendorIds.clear();

       system.debug(' in Vendor');

        for(vendorWrapper wrap : vendorWrap){

            system.debug('Vendorloop: ' + wrap.acc.get('Id'));

           system.debug('Vendorchecked: ' + wrap.vendorSelected);

            if(wrap.vendorSelected == true){

                sVendorIds += '\'' + wrap.acc.get('Id') + '\'' + ',';

                setVendorIds.add((string)wrap.acc.get('Id'));

            }

                

        }

        sVendorIds = sVendorIds.removeEnd(',');

          system.debug('Vendor: ' + sVendorIds);

        return null;

    }

 
2 risposte
  1. 28 gen 2015, 16:50
    I narrowed it down that it has nothing to do with the reRender.  The problem is that when someone check the box, it would call an Ajax function to reeavulate the list.  If i remove the ajax function and trigger it from somewhere else then it would work.  I'm not sure how I can get this to work the way it is.  
0/9000