{"id":2535,"date":"2017-05-31T11:38:57","date_gmt":"2017-05-31T11:38:57","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/salesforce\/?p=2535"},"modified":"2025-06-12T09:44:44","modified_gmt":"2025-06-12T09:44:44","slug":"expand-and-collapse-panel-using-lightning-component","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/05\/31\/expand-and-collapse-panel-using-lightning-component\/","title":{"rendered":"Expand and Collapse panel using Lightning Component"},"content":{"rendered":"<p style=\"text-align: justify;\">As mentioned in our previous blogs, we have already seen how <a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/03\/27\/add-lightning-components-to-visualforce-page\/\" target=\"_blank\" rel=\"noopener\">to use Lightning Components in our Visualforce pages<\/a> and we have also seen how to implement the look and feel of Lightning in our <a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/05\/03\/creating-a-visualforce-page-with-the-help-of-lightning-design-system\/\" target=\"_blank\" rel=\"noopener\">Visualforce pages using SLDS system<\/a>. As it stands it does seem like one-way traffic as we are only implementing Lightning and its design systems in our Salesforce Classic environment, so in this blog, we would like to go the other way around and implement something that&#8217;s available in Salesforce Classic into our Lightning system.<\/p>\n<p style=\"text-align: justify;\">The \u201c \u201d tag can create a collapsible panel\/section which based on click can expand and collapse the section\/panel based on whether the user wants to see the section\/panel or not. Although implemented in Visualforce pages for Salesforce Classic after some research we did find a quick solution to implement a collapsible panel in lightning as well.<\/p>\n<p style=\"text-align: justify;\">For its creation, we need to create a Lightning component which will constitute of a controller, helper class, and style class. And for previewing and testing purpose we will be creating a Lightning app for the same. So without any further ado, let\u2019s jump right into it.<\/p>\n<p style=\"text-align: justify;\">Create a Lightning Component via your developer console or through your IDE. Let\u2019s say the name of your Lightning component is \u201cExpand_Collapse_Panel\u201d it\u2019s relevant controller and other classes will be created. Use the below-mentioned code in your Lightning component.<\/p>\n<div id=\"attachment_2539\" style=\"width: 605px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/1.-Lightning-Component.png\" target=\"_blank\" rel=\"noopener\"><img fetchpriority=\"high\" decoding=\"async\" aria-describedby=\"caption-attachment-2539\" class=\"size-large wp-image-2539\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/1.-Lightning-Component-1024x385.png\" alt=\"Lightning Component\" width=\"595\" height=\"224\" \/><\/a><p id=\"caption-attachment-2539\" class=\"wp-caption-text\">Lightning Component<\/p><\/div>\n<p>Your Controller for Lightning component will consist of the below mentioned lines of code.<\/p>\n<div id=\"attachment_2540\" style=\"width: 654px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/2.-Controller.png\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2540\" class=\"size-full wp-image-2540\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/2.-Controller.png\" alt=\"Controller\" width=\"644\" height=\"149\" \/><\/a><p id=\"caption-attachment-2540\" class=\"wp-caption-text\">Controller<\/p><\/div>\n<p>And its helper class would be as below.<\/p>\n<div id=\"attachment_2541\" style=\"width: 707px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/3.-Helper-class.png\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2541\" class=\"size-full wp-image-2541\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/3.-Helper-class.png\" alt=\"Helper class\" width=\"697\" height=\"369\" \/><\/a><p id=\"caption-attachment-2541\" class=\"wp-caption-text\">Helper class<\/p><\/div>\n<p>Include the style classes so that you are able to toggle back and forth for expanding and collapsing the panel.<\/p>\n<div id=\"attachment_2542\" style=\"width: 391px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/4.-Style-class.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2542\" class=\"size-full wp-image-2542\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/4.-Style-class.png\" alt=\"Style class\" width=\"381\" height=\"545\" \/><\/a><p id=\"caption-attachment-2542\" class=\"wp-caption-text\">Style class<\/p><\/div>\n<p>And finally, to preview and test the same we will create a Lightning App that will refer your Lightning component and you can test the changes accordingly.<\/p>\n<div id=\"attachment_2543\" style=\"width: 998px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/5.-Lightning-App.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2543\" class=\"size-full wp-image-2543\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/5.-Lightning-App.png\" alt=\"Lightning App\" width=\"988\" height=\"351\" \/><\/a><p id=\"caption-attachment-2543\" class=\"wp-caption-text\">Lightning App<\/p><\/div>\n<div id=\"attachment_2544\" style=\"width: 582px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/6.a.-Visualforce-Page-block-collapse.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2544\" class=\"size-full wp-image-2544\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/6.a.-Visualforce-Page-block-collapse.png\" alt=\"Visualforce Page block-collapse\" width=\"572\" height=\"112\" \/><\/a><p id=\"caption-attachment-2544\" class=\"wp-caption-text\">Visualforce Page block-collapse<\/p><\/div>\n<div id=\"attachment_2545\" style=\"width: 538px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/6.b.-Visualforce-Page-block-expand.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2545\" class=\"size-full wp-image-2545\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/6.b.-Visualforce-Page-block-expand.png\" alt=\"Visualforce Page block-expand\" width=\"528\" height=\"94\" \/><\/a><p id=\"caption-attachment-2545\" class=\"wp-caption-text\">Visualforce Page block-expand<\/p><\/div>\n<div id=\"attachment_2546\" style=\"width: 605px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/7.a.-Lightning-Panel-collapse.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2546\" class=\"size-large wp-image-2546\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/7.a.-Lightning-Panel-collapse-1024x119.png\" alt=\"Lightning Panel-collapse\" width=\"595\" height=\"69\" \/><\/a><p id=\"caption-attachment-2546\" class=\"wp-caption-text\">Lightning Panel-collapse<\/p><\/div>\n<div id=\"attachment_2547\" style=\"width: 605px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/7.b.-Lightning-Panel-expand.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2547\" class=\"size-large wp-image-2547\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/05\/7.b.-Lightning-Panel-expand-1024x66.png\" alt=\"Lightning Panel-expand\" width=\"595\" height=\"38\" \/><\/a><p id=\"caption-attachment-2547\" class=\"wp-caption-text\">Lightning Panel-expand<\/p><\/div>\n<p>For a more detailed and advanced example you can refer to <a href=\"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/create-collapsible-panel-component-in-lightning\/\" target=\"_blank\" rel=\"noopener\">this blog<\/a> which would not only help you understand but would also help you delve on the same.<\/p>\n<p><span style=\"font-size: Medium;\"><strong>About Us<\/strong><\/span><br \/>\n<a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a>\u00a0as a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners across the globe. We offers Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that requires apex code incorporation into the Salesforce platform.<\/p>\n<p><a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a>\u00a0has some unique solutions for Cloud CRM such as Salesforce integration with\u00a0<a href=\"https:\/\/www.greytrix.com\/product\/sage-x3\/gumu-x3-salesforce-integration\">Sage Enterprise Management (Sage X3<\/a>),\u00a0Sage Intacct, <a href=\"https:\/\/www.greytrix.com\/product\/sage-100-erp\/gumu-100-salesforce-integration\">Sage 100\u00a0<\/a>and\u00a0<a href=\"https:\/\/www.greytrix.com\/product\/sage-300-erp\/gumu-300-salesforce-integration\">Sage 300 (Sage Accpac)<\/a>. We also offer best-in-class Cloud CRM\u00a0<a href=\"https:\/\/www.greytrix.com\/product\/crm-development\/salesforce-com\">Salesforce customization and development services<\/a> along with services such as Salesforce <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/data-migration-services\">Data Migration<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/integrated-application-development\">Integrated App development<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/custom-development\">Custom App development<\/a> and <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/maintenance-support\">Technical Support<\/a> to business partners and end users.<\/p>\n<p>Greytrix GUMU&#x2122; integration for Sage ERP \u2013 Salesforce is a 5-star app listed on <a href=\"https:\/\/appexchange.salesforce.com\/listingDetail?listingId=a0N30000000psM5EAI\" target=\"_blank\" rel=\"noopener\">Salesforce AppExchange<\/a>.<\/p>\n<p>For more information, please contact us at\u00a0<a href=\"mailto:salesforce@greytrix.com\">salesforce@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n<p><span style=\"font-size: Medium;\"><strong>Related Posts<\/strong><\/span><\/p>\n<ul>\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/05\/03\/creating-a-visualforce-page-with-the-help-of-lightning-design-system\/\" target=\"_blank\" rel=\"noopener\">Creating a VisualForce Page with the help of Lightning Design System<\/a><\/li>\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/05\/03\/gumu-feature-promote-sales-order-from-salesforce-to-sage-300-erp\/\" target=\"_blank\" rel=\"noopener\">GUMU&#x2122; Feature \u2013 Promote Sales Order from Salesforce to Sage 300 ERP<\/a><\/li>\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/05\/03\/avoiding-api-limits-in-test-classes\/\" target=\"_blank\" rel=\"noopener\">Avoiding API Limits in Test Classes<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>As mentioned in our previous blogs, we have already seen how to use Lightning Components in our Visualforce pages and we have also seen how to implement the look and feel of Lightning in our Visualforce pages using SLDS system. As it stands it does seem like one-way traffic as we are only implementing Lightning\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/05\/31\/expand-and-collapse-panel-using-lightning-component\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[47,208,209,210,215,252,388,448,518,522],"class_list":["post-2535","post","type-post","status-publish","format-standard","hentry","category-salesforce-srv","tag-collapsible-panel","tag-lightning-component","tag-lightning-design-system","tag-lightning-experience-on-salesforce","tag-lightning-to-visualforce-page","tag-page-block-section","tag-salesforce-classic","tag-sf-lightning","tag-vf-component-in-lightning","tag-visualforce"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/2535","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/comments?post=2535"}],"version-history":[{"count":1,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/2535\/revisions"}],"predecessor-version":[{"id":10934,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/2535\/revisions\/10934"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=2535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=2535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=2535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}