• arvind_kotni
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies

How to display related list in the same VF page when clicked upon any record of an object present in pageblock table ?

 

Scenario:-

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

I have pageblock table with a list of filtered opportunity records, when i try to click on any record's Edit commandlink present in pageblock table , the page should display its corresponding "OpenActivities" relatedlist below the table. Is there any way to pass the clicked record id to the <apex:relatedlist> component , so that it can open the related list using this component.

 

 

 

Please help me with the code.

 

thanks,

My Scenario:-- I am trying to pass opportunity stage name value from VF page into the class and display in return the list of Opportunity records having stage value same as stage name picklist value passed from the VF page. Also once i get all the search criteria filtered records displayed on VF page , and if i try to click on edit link on any of  the record in the pageblock table it should open its corresponding activities related list .

 

I tried passing the stage picklist value from the page to the class, the class is not able to get the value, so please help with the proper code.

 

Below is the VF page code and apex class code:-

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

 

VFpage code:-

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

 

<apex:page standardcontroller="Opportunity" extensions="oppDetailClass" recordSetVar="oplist" id="pg">
<script>
  function fun()
   {
     alert(document.getElementById('pg:f1:pb:pbs:stage').value);
   }
</script>
<apex:form id="f1">
  <apex:pageBlock id="pb">
     <apex:pageBlockSection title="Enter Opportunity Details" id="pbs">
        <apex:inputField value="{!opportunity.StartDate__c}"/>
        <apex:inputField value="{!opportunity.EndDate__c}"/>
        <apex:inputField value="{!opportunity.StageName}" id="stage"/>
        <apex:commandButton value="Search"  onclick="fun()"/>
    <!--    <apex:param name="stage" value="{!opportunity.StageName}" assignTo="{!stgname}"/>-->
       
     </apex:pageBlockSection>
     <apex:pageBlockSection title="List of sorted opportunities">
        <apex:pageblockTable value="{!oplist}" var="opl">
        <apex:column headerValue="Action">
        <apex:commandLink value="Edit">
        </apex:commandLink>
        </apex:column>
        <apex:column headerValue="Name" value="{!opl.name}"/>
        </apex:pageblockTable>
     </apex:pageBlockSection>
  </apex:pageBlock>
</apex:form>
</apex:page>

 

ApexClass code:-

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

/*public class oppDetailClass {

    public oppDetailClass(ApexPages.StandardSetController controller) {

    }
    public oppDetailClass() {

    }
    public String stgname{get;set;}
   
    //public string stage(set;get;)
    public oppDetailClass(ApexPages.StandardSetController controller) {
       
    }
       
   public pageReference search(){
        List<opportunity> oplist=new List<opportunity>();
        oplist=[select name from opportunity where stagename=:stgname];
        system.debug('---stagename---'+stgname);
        system.debug('---oplist---'+oplist);
        return null;  
    }
    public void sear()
    {
       String mystg=stgname;
       system.debug('==============>StageName'+mystg);
   
    }
}*/

public class oppDetailClass {

    public oppDetailClass(ApexPages.StandardSetController controller) {
         
    }
    public oppDetailClass() {
         
    }
    public opportunity obj;
    public List<opportunity> oplist{get;set;}
   
    public oppDetailClass(ApexPages.StandardController controller) {
      this.obj=(opportunity)controller.getrecord();
      system.debug('---obj--->'+obj);
    }
   
   
    public pageReference search(){
      oplist = new List<opportunity>();
      oplist=[select Name from opportunity where stagename=:obj.stagename];
      system.debug('----oplist---'+oplist);
      return null;
   }
}

My Scenario:-- I am trying to pass opportunity stage name value from VF page into the class and display in return the list of Opportunity records having stage value same as stage name picklist value passed from the VF page. Also once i get all the search criteria filtered records displayed on VF page , and if i try to click on edit link on any of  the record in the pageblock table it should open its corresponding activities related list .

 

I tried passing the stage picklist value from the page to the class, the class is not able to get the value, so please help with the proper code.

 

Below is the VF page code and apex class code:-

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

 

VFpage code:-

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

 

<apex:page standardcontroller="Opportunity" extensions="oppDetailClass" recordSetVar="oplist" id="pg">
<script>
  function fun()
   {
     alert(document.getElementById('pg:f1:pb:pbs:stage').value);
   }
</script>
<apex:form id="f1">
  <apex:pageBlock id="pb">
     <apex:pageBlockSection title="Enter Opportunity Details" id="pbs">
        <apex:inputField value="{!opportunity.StartDate__c}"/>
        <apex:inputField value="{!opportunity.EndDate__c}"/>
        <apex:inputField value="{!opportunity.StageName}" id="stage"/>
        <apex:commandButton value="Search"  onclick="fun()"/>
    <!--    <apex:param name="stage" value="{!opportunity.StageName}" assignTo="{!stgname}"/>-->
       
     </apex:pageBlockSection>
     <apex:pageBlockSection title="List of sorted opportunities">
        <apex:pageblockTable value="{!oplist}" var="opl">
        <apex:column headerValue="Action">
        <apex:commandLink value="Edit">
        </apex:commandLink>
        </apex:column>
        <apex:column headerValue="Name" value="{!opl.name}"/>
        </apex:pageblockTable>
     </apex:pageBlockSection>
  </apex:pageBlock>
</apex:form>
</apex:page>

 

ApexClass code:-

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

/*public class oppDetailClass {

    public oppDetailClass(ApexPages.StandardSetController controller) {

    }
    public oppDetailClass() {

    }
    public String stgname{get;set;}
   
    //public string stage(set;get;)
    public oppDetailClass(ApexPages.StandardSetController controller) {
       
    }
       
   public pageReference search(){
        List<opportunity> oplist=new List<opportunity>();
        oplist=[select name from opportunity where stagename=:stgname];
        system.debug('---stagename---'+stgname);
        system.debug('---oplist---'+oplist);
        return null;  
    }
    public void sear()
    {
       String mystg=stgname;
       system.debug('==============>StageName'+mystg);
   
    }
}*/

public class oppDetailClass {

    public oppDetailClass(ApexPages.StandardSetController controller) {
         
    }
    public oppDetailClass() {
         
    }
    public opportunity obj;
    public List<opportunity> oplist{get;set;}
   
    public oppDetailClass(ApexPages.StandardController controller) {
      this.obj=(opportunity)controller.getrecord();
      system.debug('---obj--->'+obj);
    }
   
   
    public pageReference search(){
      oplist = new List<opportunity>();
      oplist=[select Name from opportunity where stagename=:obj.stagename];
      system.debug('----oplist---'+oplist);
      return null;
   }
}