Skip to main content

Custom Accordion functionality to display related child records

  

Agenda

    


Using this blog’s functionality we are able to show any Parent-Child data or any other data of this type and we can show it in a very systematic way like an accordion.


What we are going to do.

So basically, we are going to create functionality like an accordion on our own as a custom runtime accordion and we use this to show Parent-Child data and also use runtime-local variables and other JavaScript functionalities in this lightning web component.


Lightning Web Component

First of all, What is the lightning web component?

So, The Lightning Web Components is lightweight and delivers exceptional performance. Most of the code you write is standard JavaScript and HTML.


And for more info follow the Documentation.


Now First, we need to look for the data we are going to show over the LWC, and for that, I’m using the Parent-child relationship object of Accounts and Contacts, and to fetch the data I’m using an apex method.



Apex Class:




As we discussed earlier this class is used to fetch the data from the database and use it inside the LWC and display it to the users. So, we call the @AuraEnabled method from the LWC and use the data there.


LWC JS File:



Here we are fetching accounts with its related child contacts.

And we are using local runtime-variables to show the accordion icon to handle the visibility of the contacts associated with it.



LWC HTML File:



Here we are displaying the Names of account records and with the click of the arrow, we are showing the child contact records associated with it. And we are showing - hiding the child records according to the click event on the arrow button.


Blogs Conclusion:

I Hope, this blog helps you to understand the basic structure of child-parent records and how we can show it as per the requirement. This will help you to make the visibility clearer.


Comments

Popular posts from this blog

Using Data - Attributes in Lightning Web Component (LWC)`

  Agenda      While working with Salesforce data we need to play with Id’s (Identifiers). An ID can be associated with a Record or with a specifier. While working with records when we need to make changes or view any particular record details, we need their ID’s, as I describe in my previous blog’s how can we show or edit any salesforce record with the help of Basic components of Salesforce.  To create forms that let users view, edit, and create Salesforce records, use Lightning-record-form, Lightning-record-edit-form, and Lightning-record-view form components. And To use these components we need Salesforce Record ID. Blog Details This Blog gives us a brief about how can we get a particular record Id or value after any event using Data - Attributes.  What we are going to do In this blog, we use Data - Attribute functionality from HTML5  in our Lightning Web Component and use data attribute to get...

Select - Deselect checkbox in Lightning Web Component

  Agenda In the previous blog, we are working with a single record and manipulating it as per the requirements, but when we are working for the organization we need to think to cover larger aspects. And while working with salesforce data we should be aware of the fact that we might need to work with data in bulk. So, when we need to work with more than one record we use checkbox functionality and use that checkbox to see which record we need to make changes to. Blog Details The blog gives us a brief that how we select and unselect all checkboxes from the header checkbox. What we are going to do In this blog, we use a table to show the records with the checkbox for each record and a header checkbox to select - unselect all records. Requirements: You need to have access to your org.     Should have installed the VS Code Installed in your system.    You should have some basic knowledge of Lightning Web Component. You must have some proper records ...

Displaying User Level’s Dynamically In Lightning Web Component

  Agenda I am writing this blog, to display dynamic user data beautifully, It enables each user to see the users they need to report. With this dynamic component, you can control data visibility without having to create a separate component as well, with its own running user.  Now, It’s time to show the user’s of our organization dynamically their role in a beautiful way. How does it work? You fetch the User’s record with a simple Apex SOQL query and just displaying details Dynamically over a Lightning Web Component, And place that component where ever you want. Requirements: You need to have access to your org. Should have the VS Code Installed in your system. You should have some basic knowledge of Lightning Web Component. About Lightning Web Component (LWC): Lightning Web Components are lightweight custom elements based on native HTML and Modern JavaScript. Lightning Web Compone...