Lightning Datatable example salesforce

Lightning Datatable example salesforce

Lightning Datatable example salesforce

In this blog post, I am going to explain how to use salesforce lightning:datatable component and its features. A lightning:datatable component displays tabular data where each column can be displayed based on the data type. lightning:datatable also supports inline editing. lightning:datatable is not supported on mobile devices. Following are some main features of lightning:datatable

Displaying and formatting of columns with appropriate data types

Infinite scrolling of rows

Inline editing for some data types

Header-level actions

Row-level actions

Resizing of columns

Selecting of rows

Sorting of columns by ascending and descending order

Text wrapping and clipping

Row numbering column

Cell content alignment

Tables can be populated during initialization using the data, columns, and keyField attributes. The keyField attribute is required for correct table behavior. It will associate each row with a unique identifier. The below code shows how to use the lightning: datatable to initialize the data and columns which are passed by using attributes.

In this example, we will simply display list of account using lightning:datatable.

Use the following column properties to customize the behavior and visual aspects of your columns.

PROPERTY

TYPE

DESCRIPTION

actions

object

Appends a dropdown menu of actions to a column. You must pass in a list of label-name pairs.

cellAttributes

object

Provides additional customization, such as horizontal alignment or appending an icon to the output. For more information about alignment, see Aligning Data in a Column. For more information about adding icons, see Appending an Icon to Column Data.