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
ManjeetManjeet 

PageBlockTable & DataTable issues with Ajax

Can We rerender the the above mentioned component through ajax ?

I found a No in visualforce tutorials . I need to refresh the content of a pageblocktable .

is there any way to refresh pageblockcomponent .

 

thanks in advance.........

 

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You are creating a new prospects list when the user clicks the search button, but your getProspectsList method always overwrites it based the results of this query:

 

 

prospectsList= [select name,customer_name__c,type_of_relationship__c,prospect_source__c,e_mail__c from
            prospects__c ];

 

I'd suggest you change your code to only run this query if prospectsList is null.

 

All Answers

ipsita.biswas@in.v2solutions.comipsita.biswas@in.v2solutions.com

Hi Manjeet,

Place your PageBlockTable inside an <apex:outputPanel> and rerender the outputPanel instead of the pageBlockTable.

The outputPanel will inturn rerender ur table.

ManjeetManjeet

PageBlockTable Data is not updated when i enter customer name or prospect ref no and click on search button .

 

plz let me know where i am doing mistake .........

 

 

visualforce Page

 

 

<apex:page controller="ProspectListController" sidebar="false" tabStyle="Lead">
<apex:pageblock title="Retail Client Management >> Prospects" id="theBlock"  >
<apex:form id="theForm" >
 
       
         <apex:pageblockSection columns="3" title="Search By" collapsible="false">
         
         
         <apex:pageblockSectionItem >
                   Prospect Ref No <apex:inputText value="{!prospectRefNo}" />           
           </apex:pageblockSectionItem>
            <apex:inputField value="{!Prospects.Customer_Name__c}" id="Custom123" />
            <apex:inputField value="{!Prospects.Prospect_Source__c}"  />
            <apex:inputField value="{!Prospects.Type_Of_Relationship__c}" />
            <apex:pageBlockSectionItem >
                 <apex:commandButton reRender="thePanel123,myId" action="{!search}" value="Search" />
                 
            </apex:pageBlockSectionItem>
                
         
          </apex:pageblockSection>

                 <apex:commandButton action="{!newProspect}" value="New Prospect" /> <br/>
      
    
        <apex:outputPanel id="thePanel123">
          <apex:pageBlockTable value="{!prospectsList}" var="aa"  id="mytable" >

            <apex:outputField value="{!aa.Customer_Name__c}"/>
                  <apex:column headerValue="Prospect Ref No">
                   <apex:outputLink value="/apex/ProspectDetail?id={!aa.id}" >
                        {!aa.name}
                  </apex:outputLink>
               </apex:column>
                <apex:column value="{!aa.Customer_Name__c}"  />
                <apex:column value="{!aa.Type_Of_Relationship__c}"  />
                <apex:column value="{!aa.Prospect_Source__c}"  />
      
                <apex:column headerValue="E-Mail">
                   <apex:outputLink value="mailto:{!aa.E_mail__c}" >
                        {!aa.E_mail__c}
                  </apex:outputLink>
                </apex:column>
               
          </apex:pageBlockTable>
      </apex:outputPanel>
      
           <apex:panelGrid columns="2">
              <apex:commandLink action="{!previous}" >Previous</apex:commandlink>
              <apex:commandLink action="{!next}">Next</apex:commandlink>
            </apex:panelGrid>
            
            
 
</apex:form>
     </apex:pageblock>
</apex:page>

 

 

 

Controller class

 

 

public class ProspectListController {

    List<Prospects__c> prospectsList;

    Prospects__c prospects = new Prospects__c();
    
    public String customerName { get; set; }
    public String source {get; set;}
    public String relationship { get; set ;}
    public String prospectRefNo {get;set;}    
    
     public PageReference newProspect() {
        return Page.NewProspect;
    }
    
    public PageReference search() {
    
         customerName = Prospects.customer_name__c;
         
             if(customerName != null)
              prospectsList = [ select name,customer_name__c,type_of_relationship__c,prospect_source__c,e_mail__c from
                    prospects__c where customer_name__c like :customerName limit 1 ];
           
             if(prospectRefNo != null)
               prospectsList = [ select name,customer_name__c,type_of_relationship__c,prospect_source__c,e_mail__c from
                    prospects__c where name = :prospectRefNo limit 1 ];
              Prospects = prospectsList .get(0);
             
          
            return null;
    }


    public PageReference next() {
        return null;
    }


    public PageReference previous() {
        return null;
    }

 
   
    public List<Prospects__c> getProspectsList(){
        prospectsList= [select name,customer_name__c,type_of_relationship__c,prospect_source__c,e_mail__c from
            prospects__c ];
            
            return prospectsList;
            }
       public Prospects__c getProspects(){
           return prospects;
       }
    }

bob_buzzardbob_buzzard

You are creating a new prospects list when the user clicks the search button, but your getProspectsList method always overwrites it based the results of this query:

 

 

prospectsList= [select name,customer_name__c,type_of_relationship__c,prospect_source__c,e_mail__c from
            prospects__c ];

 

I'd suggest you change your code to only run this query if prospectsList is null.

 

This was selected as the best answer
ipsita.biswas@in.v2solutions.comipsita.biswas@in.v2solutions.com

Hi Manjeet,

Remove the query from the getProspectsList() method.

 

public List<Prospects__c> getProspectsList(){
       
            if(!prospectsList.isEmpty())

            {           

                  return prospectsList;

            }

            else

            {

                  return null;

            }          

}

bob_buzzardbob_buzzard

Prospect list is null when the class is first instantiated - the above code will throw a null exception when prospectsList.isEmpty() is executed.

ManjeetManjeet

Thanks a ton sir...

ManjeetManjeet

I also have a button "RESET" that reset  all search fields .plzzz tell me how to reset the search fields when i click reset button .

does vf have any reset method like html ?