function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jennifer BERNARDJennifer BERNARD 

How to make a generic datatable component

Hello everyone.

I need to create a custom RecordList table which is using a custom ListView.

In order to do that I have created a LWC using lightning-datable just like in the Apex to Work with Data unit from Trailhead (https://trailhead.salesforce.com/content/learn/modules/lightning-web-components-and-salesforce-data/use-apex-to-work-with-data).

I would like to reuse this LWC to display different Objects' records instead of creating different component for each Object. Is it possible to use ListView for so I can get the columns automatically as well ?

I am fairly new to SalesForce development, I hope I am making sense. Thanks in advance for your help. 

Best Answer chosen by Jennifer BERNARD
ShivankurShivankur (Salesforce Developers) 
Hi Jennifer,

You can try implementing an example given on below link:
https://newstechnologystuff.com/2019/04/07/display-generic-sobject-in-lightning-web-components/

Hope above information helps, Please mark as Best Answer so that it can help others in the future.

Thanks.

All Answers

ShivankurShivankur (Salesforce Developers) 
Hi Jennifer,

You can try implementing an example given on below link:
https://newstechnologystuff.com/2019/04/07/display-generic-sobject-in-lightning-web-components/

Hope above information helps, Please mark as Best Answer so that it can help others in the future.

Thanks.
This was selected as the best answer
Mark JenniferMark Jennifer
Building a generic data-table component for registered Beginners Putter for men (https://bestputters2021.com/best-putters-for-beginners/) record, it is a table that displays any set of data in a nice tabular format and the way it is generic is, it is configurable, where to get the data from and what to display. 
User-added image
The idea is to simplify the usage of mat-table by creating a custom component that takes just the ‘path’ and the required ‘columns’ to be displayed.No more touching the ts code to manage your columns, or no need to duplicate the component logic for every mat-table you put in your application.We should be able to just drop the 2 liner html code where ever you need to display a table in your application.