Skip to content

Content Document Table

A generic table to show shared documents from a Salesforce Files library.

Available in: App Page · Home Page · Record Page · Flow Screen

custom-datatable

Read on Medium

How to build a Content Document Datatable with Apex & LWC

How to build a Content Document Datatable with Apex & LWC

Attributes

NameTypeDefaultDescription
card-iconstring'standard:file'If show card option is active, the card icon is displayed in the header before the card title. It should contain the SLDS name of the icon. Specify the name in the format 'standard:file' where 'standard' is the category and 'case' the icon to be displayed.
card-titlestring'Document Table'If show card option is active, the card title can include text and is displayed in the header above the table.
folderstringnullFolder name within Files library.
librarystring'Documents'Files library name.
record-idstringnullIf the component is used on a lightning record page, the page sets the property to the id of the current record.
show-cardbooleanfalseIf present, the table is wrapped in a lightning card to fit better into the overall page layout.
show-delete-actionbooleanfalseIf present, the last column contains a delete file action.
show-download-actionbooleanfalseIf present, the last column contains a download file action.
show-view-actionbooleanfalseIf present, the last column contains a view file action.

Usage

html
<c-content-document-table
  library="Documents"
  folder="Invoices"
  show-card
  show-view-action
  show-download-action
></c-content-document-table>

All attributes are also configurable in the Lightning App Builder, so no code is required to use the component.

Component Dependencies

NameTypeDescription
contentDocumentIconLWCCustom datatable cell type to display the appropriate icon based on the file type.
contentDocumentPreviewLWCCustom datatable cell type that is used to display a file preview when clicking on the title.
contentDocumentTableExtensionLWCCustom extension of the standard LWC datatable to support individual table cell types.
ContentDocumentControllerApexController class for retrieving content documents from files library.
ContentDocumentControllerTestApexTest class for ContentDocumentController.

Released under the MIT License.