table/src/table/table.component.ts
The Table component renders tabular data.
// Component class
import { ITableColumn, ITableRow } from '@talenra/components/table';
protected readonly columns: ITableColumn[] = [
{ identifier: '0', field: 'author', label: 'Author' },
{ identifier: '1', field: 'title', label: 'Title' },
{ identifier: '2', field: 'isbn', label: 'ISBN' },
];
protected readonly data: ITableRow[] = [
{
identifier: "e5472204-4410-479a-9e90-c591dc8329e5",
author: "Gabrielle-Suzanne Barbot de Villeneuve",
title: "La Belle et la Bête",
isbn: "978-1-910-88006-7",
},
{
identifier: "6cf48942-341d-4b3d-b76a-be444a3f46dc",
author: "Mary Shelley",
title: "Frankenstein; or, The Modern Prometheus",
isbn: "978-1-530-27844-2",
},
{
identifier: "0e1ea95b-5e9b-4638-be2d-419c1455ea2e",
author: "Herman Melville",
title: "Moby-Dick; or, The Whale",
isbn: "978-1-530-69790-8",
}
]<!-- Component template -->
<talenra-table [columns]="columns" [data]="data" />Input property columns is key to to configure the Table and assign keys from your data object to Table columns.
String values are supported out of the box. Provide a cell-renderer component if you need to display more complex data or UI (icons, checkboxes, links, graphs, …). The custom cell-renderer component has access to the cell's context.
The width of tables is controlled by the containing element. Tables are the same width as their container.
import { TableComponent } from '@talenra/components/table';
| changeDetection | ChangeDetectionStrategy.OnPush |
| host | { |
| selector | talenra-table |
| imports |
NgTemplateOutlet
FormsModule
CheckboxComponent
FieldUnderlineComponent
IconComponent
MessageComponent
ScrollContainerComponent
SkeletonComponent
TableCellRendererDirective
TooltipDirective
DragDropModule
DoubleClickDirective
|
| styleUrls | ./table.component.scss, |
| templateUrl | ./table.component.html |
Inputs |
Outputs |
| columns |
Type : ITableColumn[]
|
Default value : []
|
|
Array of column definitions. Used to configure the table's columns including the column header. While the Custom cell rendererOut of the box, the Table renders string values. Custom renderer component allow you to implement more complex layout, interaction: From a simple icon indicating state to a button or a complex chart – all these use-cases involve a custom cell-renderer component. Your custom component will be rendered in the table cell and be provided with context (table data). This requires
to implement the The renderer component is then assigned to a column as in the example below. Example :Two-way bindingAn event is emitted when columns is updated. Listen to the event to persist the column configuration (e.g. store column widths when resized by the user). Example :See ITableColumn See ITableCellContext |
| customMessages |
Type : ITableMessages | undefined
|
Default value : undefined
|
|
Custom messages/translations will override default messages provided via localize. Use this feature if your app involves multiple instances of Table using different messages per instance. If all Table instances of your app share the same messages, you should provide/customize messages via localization instead. Note that custom messages can be translated using the |
| data |
Type : ITableRow[]
|
Default value : []
|
|
Table data, represented by an array of table rows. The provided data's fields are matched to the Table's columns based on the See ITableRow |
| selectionMode |
Type : TTableSelectionMode
|
Default value : TableSelectionMode.None
|
|
Determines whether rows are selectable or not. Supports single-row or multi-row selection. Example : |
| sortState |
Type : ITableSortState | null
|
Default value : null
|
|
The current sort state. Input a value to pre-set sort and/or use two-way binding to update the sort state programmatically. Note that the Table component does not sort data. It is up to the consuming app to update data based on the sort state. Here's an implementation example. Example :
|
| columns |
Type : ITableColumn[]
|
|
Array of column definitions. Used to configure the table's columns including the column header. While the Custom cell rendererOut of the box, the Table renders string values. Custom renderer component allow you to implement more complex layout, interaction: From a simple icon indicating state to a button or a complex chart – all these use-cases involve a custom cell-renderer component. Your custom component will be rendered in the table cell and be provided with context (table data). This requires
to implement the The renderer component is then assigned to a column as in the example below. Example :Two-way bindingAn event is emitted when columns is updated. Listen to the event to persist the column configuration (e.g. store column widths when resized by the user). Example :See ITableColumn See ITableCellContext |
| data |
Type : ITableRow[]
|
|
Table data, represented by an array of table rows. The provided data's fields are matched to the Table's columns based on the See ITableRow |
| rowDoubleClick |
Type : ITableRowDoubleClick
|
|
Event emitted if a row is double clicked. Contains the relevant row and the mouse event. Requires
|
| rowSelectionChange |
Type : ITableRowSelectionChange
|
|
Event emitted when a row is un-/selected. Contains the relevant row and its selection state. Example : |
| sortState |
Type : ITableSortState | null
|
|
The current sort state. Input a value to pre-set sort and/or use two-way binding to update the sort state programmatically. Note that the Table component does not sort data. It is up to the consuming app to update data based on the sort state. Here's an implementation example. Example :
|