Dynamic Lightning Table

Dynamic lightning table components help you to easily display records in the table format along with the pagination


This component has three attributes
1. Object - Specify the API name of the object from where you need to retrieve the records
2. Fields - Specify the list of columns you wants to display in the table. You have to mention the API name of the object fields
3. pageSize - Specify the number of records you want to display in a page

Let's look into the components involved here

DataTable
In my recent post about the custom lightning component for recent records, I have provided an example to display the records dynamically, the same component logic remains here, the only differences here is instead of the recent record object, we will retrieve the records from the actual object. Check the blog post here - https://clicksandcode.blogspot.ca/2015/12/recent-items-custom-lightning-components.html



Pagination
Pagination logic is the one of the key features for the data table to navigate and view the records for the users when there are a large number of records available in an object.This lightning table has pagination component which helps you to navigate in the table


The paginator components have three attributes

  • Page - To display the current page
  • Pages - Total number of pages in the table
  • total - To display total number of record in the table

When there is button click event occurs it will fire the PageChange event and set the direction in the parameter. Based on that lightning controller in the lightning table it will show the previous or next page of the table.


Stay tuned!!! More features are coming to this component like search and sorting in the table. If you would like to contribute, the complete source code is available on the GitHub, feel free to fork.
https://github.com/Karanraj/Dynamic-Lightning-Table

You can also deploy this component using the below deploy to salesforce button

Deploy to Salesforce

Comments

Popular Posts