Table Data Hds
<sl-table-data-hds> | SlTableDataHds
            Data table component to display data in a tabular format.
Examples
Data Table Example
<sl-table-data-hds id="hds-data-table"></sl-table-data-hds> <script> const dataTable = document.getElementById('hds-data-table'); dataTable.chartTitle = "Special DataTable Example" dataTable.rowHover = true; dataTable.striped = true; // NOTE: the 'status' keyword transforms the values into labels dataTable.columns = ['name', 'age', 'city', 'editable input', 'status']; dataTable.editableColumns = ['city', 'editable input'] dataTable.data = [ { id: 1, rows: [ 'Alice', 12, 'New York', 'A value that needs to be edited', 'Active' ] }, { id: 2, rows: [ 'Jim', 38, 'Victoria', 'A value that needs to be edited', 'Inactive'] }, { id: 3, rows: [ 'Bob', 50, 'Western AUS', 'A value that needs to be edited', 'Pending'] }, { id: 4, rows: [ 'Peter', 29, 'TN', 'A value that needs to be edited', 'Active'] }, { id: 5, rows: [ 'Joe', 30, 'NSW', 'A value that needs to be edited', 'Active'] }, ]; // Example of capturing data when editing a cell document.getElementById('hds-data-table').addEventListener('cell-edit', (event) => { const { id, rowIndex, colIndex, updatedValue } = event.detail; console.log(`Cell updated record id: ${id} at row ${rowIndex}, column ${colIndex}: ${updatedValue}`); // Handle the update, e.g., save to a server or update local state }); // Example of capturing selected row data document.getElementById('hds-data-table').addEventListener('selection-change', (event) => { const { selectedRowIds } = event.detail; console.log(`Id's of rows selected: ${selectedRowIds}`); // Handle the update, e.g., save to a server or update local state }); // Example of capturing action click on row eye document.getElementById('hds-data-table').addEventListener('row-action', (event) => { const { id } = event.detail; console.log(`Id of row: ${id}`); // Handle the update, e.g., save to a server or update local state }); </script>
Second Example
TODO
[component-metadata:sl-table-data-hds]
Slots
| Name | Description | 
|---|---|
| (default) | The default slot. | 
Learn more about using slots.
Properties
| Name | Description | Reflects | Type | Default | 
|---|---|---|---|---|
| data | The data to be displayed in the table. |  | TableData[] | [] | 
| columns | The titles to be displayed in the table header columns. | string[] | [] | |
| editableColumns editable-columns  | Defines which columns will be editable. | string[] | [] | |
| chartTitle table-title  | The title of the data table. | string | '' | |
| rowHover row-hover  | Adds hover effect to the table rows. | boolean | false | |
| striped | Adds alternating stripes to the table rows. | boolean | false | |
| updateComplete | A read-only promise that resolves when the component has finished updating. | 
Learn more about attributes and properties.
Events
| Name | React Event | Description | Event Detail | 
|---|---|---|---|
| cell-edit |  | event emitted when a cell is edited. | - | 
| selection-change |  | event emitted when the selection changes. | - | 
| row-action |  | event emitted when a row action is clicked. | - | 
Learn more about events.
Parts
| Name | Description | 
|---|---|
| base | The component’s base wrapper. | 
Learn more about customizing CSS parts.
Dependencies
This component automatically imports the following dependencies.
- <sl-checkbox>
- <sl-icon>
- <sl-icon-button>
- <sl-input>