I am working on the lightning web component. I have to create a table of Account records to show on UI. And Make them editable.
How can I achieve this with best practices?
Please answer me ?
3 respuestas
Hi @Sita Ram Rawat,
I hope you are doing great. if your issue has not yet been resolved.
There are two ways that can be used to show data on the UI on LWC.
- Both lightning-datatable and lightning-record-edit-form are Lightning Web Components that allow you to work with data in different ways.
- If you use lightning-datatable, you can display data in a tabular format with features like sorting, filtering, and pagination. However, to make the table data editable, you will need to create custom edit functionality, which can be time-consuming and require more development effort.
- If you use lightning-record-edit-form, you can easily create an edit form for a single record. It provides a pre-built form that automatically renders fields based on the record's metadata and allows you to update the record fields without writing custom code. However, you will need to use other components, like lightning-input-field, to display and edit the record fields.
- If you need to display a table of data that needs to be edited frequently, it may be preferable to use lightning-record-edit-form to simplify the development process. However, if you only need to display data in a tabular format and editing is not a frequent requirement, then lightning-datatable can be a better choice because it provides more features and customization options.
Reference:
1. Lightning Record Page:
2. Lightning Datatable:
https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/example
My replies should help you resolve your issue.