Toggle Side Panel

  • Blogs
  • Consultants
    • Salesforce Product Expertise
      • Top Salesforce ConsultantsTop Salesforce Consultants
      • Marketing Cloud ConsultantsMarketing Cloud Consultants
      • Service Cloud ConsultantsService Cloud Consultants
      • Experience Cloud ConsultantsExperience Cloud Consultants
      • Analytics Cloud ConsultantsAnalytics Cloud Consultants
    • Salesforce Industry Expertise
      • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
      • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
      • Health Cloud ConsultantsHealth Cloud Consultants
      • Commerce Cloud ConsultantsCommerce Cloud Consultants
      • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
    • Salesforce Experts by Location
      • USATop Salesforce Consultants in USA
      • IndiaTop Salesforce Consultants in India
      • AustraliaTop Salesforce Consultants in Australia
      • United KingdomTop Salesforce Consultants in UK
      • CanadaTop Salesforce Consultants in Canada
  • Webinars
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Blogs
    • Consultants
      • Salesforce Product Expertise
        • Top Salesforce ConsultantsTop Salesforce Consultants
        • Marketing Cloud ConsultantsMarketing Cloud Consultants
        • Service Cloud ConsultantsService Cloud Consultants
        • Experience Cloud ConsultantsExperience Cloud Consultants
        • Analytics Cloud ConsultantsAnalytics Cloud Consultants
      • Salesforce Industry Expertise
        • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
        • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
        • Health Cloud ConsultantsHealth Cloud Consultants
        • Commerce Cloud ConsultantsCommerce Cloud Consultants
        • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
      • Salesforce Experts by Location
        • USATop Salesforce Consultants in USA
        • IndiaTop Salesforce Consultants in India
        • AustraliaTop Salesforce Consultants in Australia
        • United KingdomTop Salesforce Consultants in UK
        • CanadaTop Salesforce Consultants in Canada
    • Webinars
    • Contact Us
    • Discussions
    Close search

    Activity › Forums › Salesforce® Discussions › How to show related contacts under account in a Salesforce Visualforce page?

    Tagged: Account Detail, Contact Record, Dynamic Visualforce, Salesforce Visualforce Page, Visualforce Component

    • Salesforce® Discussions

      How to show related contacts under account in a Salesforce Visualforce page?

      Posted by Radhakrishna on August 21, 2017 at 4:03 AM

      I'm displaying all accounts in a visual force page where each row is having a first column as a '+'(expands). On clicking of symbol i wants to show related contacts under the same account.When I click on symbol account columns should be displayed in single row only and contacts should come below.

      Shubham replied 9 years ago 3 Members · 2 Replies
      • Account Detail
      • Contact Record
      • Dynamic Visualforce
      • Salesforce Visualforce Page
      • Visualforce Component
    • 2 Replies
    • Neha

      Member
      August 21, 2017 at 12:22 PM

      Hello Radhakrishna,

      Please go through my earlier post at: VISIT HERE

      Hope it will help you.

      • This reply was modified 9 years ago by  Neha.
    • [adinserter block='9']
    • Shubham

      Member
      August 21, 2017 at 1:00 PM

      Hello RadhaKrishna

      Please Try below Code

      Controller -

      public class actocons
      {
      public list<account> acct{set;get;}
      public actocons()
      {
      acct=[select id,name,(select id,lastname from contacts)from account limit 5];
      }
      }

      VisualForce Page -

      <apex:page controller="actocons" tabStyle="Account">
      <apex:pageBlock >
      <apex:repeat value="{!acct}" var="a">
      <apex:pageBlockSection id="section1" title="{!a.name}" onclick="document.getElementById('{!$Component.section1}').childNodes[0].childNodes[0].click();">
      <script>twistSection(document.getElementById("{!$Component.section1}").childNodes[0].childNodes[0]);document.getElementById("{!$Component.section1}").childNodes[0].style.cssText = "cursor:pointer;" </script>
      <apex:outputField value="{!a.Name}"/>
      <apex:pageBlockTable value="{!a.Contacts}" var="c" id="j1">
      <apex:column value="{!c.id}" />
      <apex:column value="{!c.lastname}"/>
      </apex:pageBlockTable>
      </apex:pageBlockSection>
      </apex:repeat>
      </apex:pageBlock>
      <script>
      twistSection = (function() {
      var cached_function = twistSection;

      return function(twisty, sectionId) {
      cached_function.apply(this, arguments); // use .apply() to call the original twistSection function provided by Salesforce
      if (event.stopPropagation) {
      event.stopPropagation();
      } else {
      event.cancelBubble = true;
      }
      };
      }());

      </script>
      </apex:page>

    Log In to reply.

    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me

    Popular Salesforce Blogs

    Details About Separation of Concerns

    Details About Separation of Concerns | Salesforce Developer Guide

    Blog in Salesforce Apex

    At the point when You Don't Need SOC on Force.com One critical advantage of Force.com is its definitive improvement model that allows you to make…

    API, APIs, Application, Approval Rules, Batch Apex
    Shweta Choudhary Oct 27, 2021
    2,409  Views

    Salesforce Chatbot: Streamlining Customer Service and Support

    Blog in Salesforce

    Introduction Salesforce Chatbot is an AI-powered conversational agent designed to interact with customers in a natural and human-like manner. It leverages advanced NLP algorithms and…

    Applications, Appointment Scheduling, Automated Responses, Automation, Call Routing
    Cymetrix Aug 7, 2023
    1,798  Views

    Driving Business Value with Salesforce Marketing Cloud

    Blog in Salesforce

    When you approve a Salesforce Marketing Cloud implementation, you’re not just investing in email automation. You are investing in long-term competitive advantage, operational effectiveness, customer…

    Salesforce, Salesforce Marketing Cloud
    SP Mar 30, 2026
    198  Views

    Popular Salesforce Videos

    Build Your First Salesforce IoT Project in 20 Minutes

    Build Your First Salesforce IoT Project in 20 Minutes

    Video in Internet of Things

    Join us to see how you can build your first Salesforce IoT orchestration in less than 20 minutes! You will learn a quick overview of…

    Salesforce IoT, Salesforce IoT Project, Salesforce IoT Tutorial, Salesforce IoT Development, Salesforce IoT Training
    Prafull Apr 24, 2018
    2,657  Views
    Getting Started With Business Analysis | Scrum Development Model | Salesforce Tutorial

    Getting Started With Business Analysis | Scrum Development Model | Salesforce Tutorial

    Video in Others, Salesforce Training, Salesforce Development

    Learn all about AGILE software development and the scrum development model. 1. Introduction To AGILE Get a brief definition of AGILE and its different modules.…

    Salesforce Training, Salesforce Tutorial, Agile, Salesforce Video, Business Analysis
    Algoworks Feb 8, 2021
    2,519  Views
    Pass Salesforce Certification Exam In Your First Attempt

    Pass Salesforce Certification Exam In Your First Attempt

    Video in Salesforce Stories

    This Salesforce Training Video will help you understand the concepts of Salesforce and Salesforce exam so that you can pass the Salesforce exam in the…

    Salesforce Training, Salesforce Certification, Salesforce Developer, Salesforce Community, Salesforce Tools
    Simplilearn Apr 23, 2019
    1,817  Views
    Footer Forcetalks logo

    support@forcetalks.com

    • twitterx

    Quick Links

    Advertise with Us

    Salesforce® Articles

    Dreamforce 2023

    Top Salesforce® Bloggers 2023

    Top Salesforce Consultants

    Get Listed

    Company

    Contact Us

    About Us

    Privacy Policy

    Terms & Conditions

    InsightHub

    Salesforce Blogs

    Salesforce Videos

    Salesforce Groups

    Salesforce Jobs

    © 2026 - Forcetalks ● All Rights Reserved

    Salesforce® is a trademark of Salesforce® Inc. No claim is made to the exclusive right to use “Salesforce”. Any services offered within the Forcetalks website/app are not sponsored or endorsed by Salesforce®.

    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.