Skip to main content
Hi All,

I am new to salesforce.

I have on requirment.When i click on "Show All leads" button on that time only records need to display with new page block.

Below are my code:

-----------------------------------

VF page

----------------------

<apex:page standardController="Lead" Extensions="DisplayingListofrecords_Controller">

<apex:form >

  <apex:pageBlock title="For buttons">

       <apex:commandButton action="{!ShowLeads}" value="Show Leads" reRender="Details"/>

  </apex:pageBlock>

</apex:form>

<apex:outputPanel id="Details">

<apex:actionStatus startText="Requesting............">

  <apex:pageBlock title="Displaying List of accounts" id="Showlistofleads" rendered="false">

    <apex:dataTable value="{!leadlist}" var="a" cellpadding="4" border="1">

        <apex:column >

              <apex:facet name="header">Name</apex:facet>

              {!a.Name}

        </apex:column>  

        <apex:column >

              <apex:facet name="header">Company</apex:facet>

              {!a.Company}

        </apex:column>  

        <apex:column >

              <apex:facet name="header">Status</apex:facet>

              {!a.Status}

        </apex:column>  

        <apex:column >

              <apex:facet name="header">Industry</apex:facet>

              {!a.Industry}

        </apex:column>  

        <apex:column >

              <apex:facet name="header">Email</apex:facet>

              {!a.Email}

        </apex:column>  

        <apex:column >

              <apex:facet name="header">LeadSource</apex:facet>

              {!a.LeadSource}

        </apex:column>  

        <apex:column >

              <apex:facet name="header">Lead Score</apex:facet>

              {!a.Lead_Score__c}

        </apex:column>          

    </apex:dataTable>

</apex:pageBlock>

</apex:actionStatus>

</apex:outputPanel>

</apex:page>

Controller

-------------------

public with sharing class DisplayingListofrecords_Controller {

    Public List<Lead> leadlist {get;set;}

    public DisplayingListofrecords_Controller(ApexPages.StandardController controller) {

     

   

    }

    

    public PageReference ShowLeads()

    {

         leadlist = [select Name,Company,Status,Industry,Email,LeadSource,Lead_Score__c from lead];

         

         return null;

    }

}

 
4 respuestas
  1. 15 mar 2018, 09:41
    Hey Naveen,

    Paste below code-

    <apex:page standardController="Lead" Extensions="DisplayingListofrecords_Controller">

    <apex:form id="theform">

    <apex:pageBlock title="For buttons">

    <apex:commandButton action="{!ShowLeads}" value="Show Leads" reRender="theform"/>

    <apex:actionStatus startText="Requesting............"></apex:actionStatus>

    <apex:pageBlock title="Displaying List of accounts" id="Showlistofleads" rendered="true">

    <apex:dataTable value="{!leadlist}" var="a" cellpadding="4" border="1">

    <apex:column >

    <apex:facet name="header">Name</apex:facet>

    {!a.Name}

    </apex:column>

    <apex:column >

    <apex:facet name="header">Company</apex:facet>

    {!a.Company}

    </apex:column>

    <apex:column >

    <apex:facet name="header">Status</apex:facet>

    {!a.Status}

    </apex:column>

    <apex:column >

    <apex:facet name="header">Industry</apex:facet>

    {!a.Industry}

    </apex:column>

    <apex:column >

    <apex:facet name="header">Email</apex:facet>

    {!a.Email}

    </apex:column>

    <apex:column >

    <apex:facet name="header">LeadSource</apex:facet>

    {!a.LeadSource}

    </apex:column>

    <apex:column >

    <apex:facet name="header">Lead Score</apex:facet>

    {!a.Lead_Score__c}

    </apex:column>

    </apex:dataTable>

    </apex:pageBlock>

    </apex:pageBlock>

    </apex:form>

    </apex:page>

     

    public with sharing class DisplayingListofrecords_Controller {

    Public List<Lead> leadlist {get;set;}

    public DisplayingListofrecords_Controller(ApexPages.StandardController controller) {

    }

    public PageReference ShowLeads()

    {

    leadlist = [select Name,Company,Status,Industry,Email,LeadSource from lead];

    return null;

    }

    }

    Hit Best answer if it resolved your issue.

    Happy Coding.

     
0/9000