table/src/lib/table/table.component.ts
Angular Material Table with Sort Feature
| host | { |
| selector | hra-table |
| imports |
HraCommonModule
MarkdownModule
MatMenuModule
MatSortModule
MatTableModule
ScrollingModule
MatCheckboxModule
TextHyperlinkDirective
LinkRowElementDirective
TextRowElementDirective
MarkdownRowElementDirective
MenuButtonRowElementDirective
NumericRowElementDirective
PlainTooltipDirective
IconsModule
ButtonsModule
|
| templateUrl | table.component.html |
| styleUrl | table.component.scss |
Properties |
Methods |
Inputs |
Outputs |
constructor()
|
|
Defined in table/src/lib/table/table.component.ts:268
|
|
Sort data on load and set columns |
| columns | |
Type : TableColumn[]
|
|
|
Defined in table/src/lib/table/table.component.ts:174
|
|
|
Columns in table |
|
| csvUrl | |
Type : string
|
|
|
Defined in table/src/lib/table/table.component.ts:171
|
|
|
CSV URL input |
|
| enableRowSelection | |
Type : boolean
|
|
Default value : false
|
|
|
Defined in table/src/lib/table/table.component.ts:189
|
|
|
Enable row selection with checkboxes |
|
| enableSort | |
Type : boolean
|
|
Default value : false
|
|
|
Defined in table/src/lib/table/table.component.ts:183
|
|
|
Enables sorting |
|
| hideHeaders | |
Type : boolean
|
|
Default value : false
|
|
|
Defined in table/src/lib/table/table.component.ts:192
|
|
|
Hide table headers |
|
| rows | |
Type : T[]
|
|
|
Defined in table/src/lib/table/table.component.ts:177
|
|
|
Unsorted data |
|
| style | |
Type : TableVariant
|
|
Default value : 'alternating'
|
|
|
Defined in table/src/lib/table/table.component.ts:180
|
|
|
Table style |
|
| verticalDividers | |
Type : boolean
|
|
Default value : false
|
|
|
Defined in table/src/lib/table/table.component.ts:186
|
|
|
Enables dividers between columns |
|
| downloadHovered | |
Type : string
|
|
|
Defined in table/src/lib/table/table.component.ts:201
|
|
|
Emits download object id on download button hover |
|
| routeClicked | |
Type : string
|
|
|
Defined in table/src/lib/table/table.component.ts:198
|
|
|
Emits route |
|
| selectionChange | |
Type : T[]
|
|
|
Defined in table/src/lib/table/table.component.ts:195
|
|
|
Emits when selection changes |
|
| download | ||||||||
download(url: string)
|
||||||||
|
Defined in table/src/lib/table/table.component.ts:362
|
||||||||
|
Downloads a file from the url
Parameters :
Returns :
void
|
| downloadButtonHover | ||||||
downloadButtonHover(id: string | number | boolean | (string | number | boolean)[])
|
||||||
|
Defined in table/src/lib/table/table.component.ts:354
|
||||||
|
Emits the id of a row when its download button is hovered
Parameters :
Returns :
void
|
| getColumnType | ||||||||
getColumnType(column: TableColumn)
|
||||||||
|
Defined in table/src/lib/table/table.component.ts:286
|
||||||||
|
Returns the column type for a given column.
Parameters :
Returns :
TableColumnType
Column type |
| getMenuOptions | ||||||||
getMenuOptions(options: string | number | boolean | MenuOptionsType[])
|
||||||||
|
Defined in table/src/lib/table/table.component.ts:344
|
||||||||
|
Returns download menu options as an array of MenuOptionsType
Parameters :
Returns :
MenuOptionsType[]
Menu options as an array of MenuOptionsType |
| isAllSelected |
isAllSelected()
|
|
Defined in table/src/lib/table/table.component.ts:313
|
|
Whether the number of selected elements matches the total number of rows.
Returns :
boolean
|
| routeClick | ||||||
routeClick(url: string | number | boolean | (string | number | boolean)[])
|
||||||
|
Defined in table/src/lib/table/table.component.ts:349
|
||||||
|
Emits a route as string when object label is clicked
Parameters :
Returns :
void
|
| scrollToTop |
scrollToTop()
|
|
Defined in table/src/lib/table/table.component.ts:367
|
|
Scrolls to top of the table
Returns :
void
|
| toggleAllRows |
toggleAllRows()
|
|
Defined in table/src/lib/table/table.component.ts:322
|
|
Selects all rows if they are not all selected; otherwise clear selection.
Returns :
void
|
| toggleRow | ||||||
toggleRow(row: TableRow)
|
||||||
|
Defined in table/src/lib/table/table.component.ts:334
|
||||||
|
Toggle row selection
Parameters :
Returns :
void
|
| Protected Readonly _columns |
Type : unknown
|
Default value : computed(() => this.columns() ?? this.inferColumns(this._rows()))
|
|
Defined in table/src/lib/table/table.component.ts:243
|
|
Table data columns |
| Protected Readonly _rows |
Type : unknown
|
Default value : computed(() => this.rows() ?? this.csv.value())
|
|
Defined in table/src/lib/table/table.component.ts:240
|
|
Table data rows |
| Protected Readonly columnIds |
Type : unknown
|
Default value : computed(() => {
const columns = this._columns().map((col) => col.column);
return this.enableRowSelection() ? ['select', ...columns] : columns;
})
|
|
Defined in table/src/lib/table/table.component.ts:246
|
|
Table data column IDs |
| Protected Readonly dataSource |
Type : unknown
|
Default value : new MatTableDataSource<T>([])
|
|
Defined in table/src/lib/table/table.component.ts:268
|
|
Table data source |
| Readonly scrollbar |
Type : unknown
|
Default value : viewChild.required<NgScrollbar>('scrollbar')
|
|
Defined in table/src/lib/table/table.component.ts:204
|
|
Scrollbar ref |
| Readonly selection |
Type : unknown
|
Default value : new SelectionModel<TableRow>(true, [])
|
|
Defined in table/src/lib/table/table.component.ts:210
|
|
Selection model for checkbox functionality |
| Readonly snackbar |
Type : unknown
|
Default value : inject(SnackbarService)
|
|
Defined in table/src/lib/table/table.component.ts:219
|
|
Snackbar service for download notification |
| Protected Readonly totals |
Type : unknown
|
Default value : computed(() => {
const result = new Map<TableColumn, number>();
for (const col of this._columns()) {
const options = this.getColumnType(col);
if (options.type === 'numeric' && options.computeTotal) {
const total = this._rows().reduce((acc, row) => {
const value = Number(row[col.column as keyof T]);
return acc + (Number.isNaN(value) ? 0 : value);
}, 0);
result.set(col, total);
}
}
return result;
})
|
|
Defined in table/src/lib/table/table.component.ts:252
|
|
Totals by column for which |