Data Grid
Allows users to interact with data in a tabular format.
Use the Data Grid Row and Data Grid Cell sub-components inside of Data Grid's default slot to construct the tabular data like you would using tr and td tags inside of a table element.
Content can also be passed to the Data Grid programically using the rowsData property.
A grid header can be provided by setting:
row-typeattribute on Data Grid Row toheaderorsticky-header(for a header that stick to the top while the body is scrollable)cell-typeon Data Grid Cells tocolumnheader
Use the grid-template-columns attribute to set the width of the grid columns.
Values match the CSS grid-template-columns property.
Use the fixed-columns attribute to set the number of the fixed grid columns. These columns will remain fixed to the left edge of the grid when scrolling horizontally.
Use the selection-mode attribute to specify the how cells or rows can be selected.
none(default) - cells or row can not be selectedsingle-cell- one cell can be selectedmulti-cell- multiple cells can be selected by holding theSHIFTkeysingle-row- one row can be selectedmulti-row- multiple rows can be selected by holding theSHIFTkey
Use the aria-selected attribute to indicate that the selected state of the row or cell.
For selection functionality to work correctly, the selection-mode attribute (on Data Grid) must be set to the relevant value.
Use the sort-direction attribute on a columnheader cell to indicate the sortable state of a header cell.
This will add the right chevron(s) according to the state.
ascending- Items are sorted in ascending order by this column. Will show one chevron pointing up.descending- Items are sorted in descending order by this column. Will show one chevron pointing down.none- There is no defined sort applied to the column. Will show indeterminate state with the two chevrons.other- A sorting algorithm other than ascending or descending has been applied. Will show no hint.
The sortable feature doesn't actually sort the data, it only changes the visual representation of the column header. See the sorting use case for more information.