import {CdkTableModule} from '@angular/cdk/table';
CdkTable
A data table that renders a header row and data rows. Uses the dataSource input to determine the data to be rendered. The data can be provided either as a data array, an Observable stream that emits the data array to render, or a DataSource with a connect function that will return an Observable stream that emits the data array to render.
Selector: cdk-table
Exported as: cdkTableName | Description |
---|---|
@Input()
| The table's source of data, which can be provided in three ways (in order of complexity):
If a data array is provided, the table must be notified when the array's objects are added, removed, or moved. This can be done by calling the When providing an Observable stream, the table will trigger an update automatically when the stream emits a new array of data. Finally, when providing a |
@Input()
| Tracking function that will be used to check the differences in data changes. Used similarly to |
| Stream containing the latest information on what rows are being displayed on screen. Can be used by the data source to as a heuristic of what data should be provided. |
addColumnDef | |
---|---|
Adds a column definition that was not included as part of the direct content children. | |
Parameters | |
columnDef CdkColumnDef |
addRowDef | |
---|---|
Adds a row definition that was not included as part of the direct content children. | |
Parameters | |
rowDef CdkRowDef<T> |
removeColumnDef | |
---|---|
Removes a column definition that was not included as part of the direct content children. | |
Parameters | |
columnDef CdkColumnDef |
removeRowDef | |
---|---|
Removes a row definition that was not included as part of the direct content children. | |
Parameters | |
rowDef CdkRowDef<T> |
renderRows | |
---|---|
Renders rows based on the table's latest set of data, which was either provided directly as an input or retrieved through an Observable stream (directly or from a DataSource). Checks for differences in the data since the last diff to perform only the necessary changes (add/remove/move rows). If the table's data source is a DataSource or Observable, this will be invoked automatically each time the provided Observable stream emits a new data array. Otherwise if your data is an array, this function will need to be called to render any changes. |
setHeaderRowDef | |
---|---|
Sets the header row definition to be used. Overrides the header row definition gathered by using | |
Parameters | |
headerRowDef CdkHeaderRowDef |
CdkCellDef
Cell definition for a CDK table. Captures the template of a column's data row cell as well as cell-specific properties.
Selector: [cdkCellDef]
CdkHeaderCellDef
Header cell definition for a CDK table. Captures the template of a column's header cell and as well as cell-specific properties.
Selector: [cdkHeaderCellDef]
CdkColumnDef
Column definition for the CDK table. Defines a set of cells available for a table column.
Selector: [cdkColumnDef]
Name | Description |
---|---|
@Input('cdkColumnDef')
| Unique name for this column. |
| Transformed version of the column name that can be used as part of a CSS classname. Excludes all non-alphanumeric characters and the special characters '-' and '_'. Any characters that do not match are replaced by the '-' character. |
CdkHeaderCell
Header cell template container that adds the right classes and role.
Selector: cdk-header-cell
CdkCell
Cell template container that adds the right classes and role.
Selector: cdk-cell
CdkHeaderRowDef
extends BaseRowDefHeader row definition for the CDK table. Captures the header row's template and other header properties such as the columns to display.
Selector: [cdkHeaderRowDef]
Name | Description |
---|---|
@Input( cdkHeaderRowDef)
| The columns to be displayed on this row. |
getColumnsDiff | |
---|---|
Returns the difference between the current columns and the columns from the last diff, or null if there is no difference. | |
Returns | |
IterableChanges<any> | null |
CdkRowDef
extends BaseRowDefData row definition for the CDK table. Captures the header row's template and other row properties such as the columns to display and a when predicate that describes when this row should be used.
Selector: [cdkRowDef]
Name | Description |
---|---|
@Input( cdkRowDefColumns)
| The columns to be displayed on this row. |
@Input( cdkRowDefWhen)
| Function that should return true if this row template should be used for the provided index and row data. If left undefined, this row will be considered the default row template to use when no other when functions return true for the data. For every row, there must be at least one when function that passes or an undefined to default. |
getColumnsDiff | |
---|---|
Returns the difference between the current columns and the columns from the last diff, or null if there is no difference. | |
Returns | |
IterableChanges<any> | null |
CdkHeaderRow
Header template container that contains the cell outlet. Adds the right class and role.
Selector: cdk-header-row
CdkRow
Data row template container that contains the cell outlet. Adds the right class and role.
Selector: cdk-row
BaseRowDef
Base class for the CdkHeaderRowDef and CdkRowDef that handles checking their columns inputs for changes and notifying the table.
Name | Description |
---|---|
| The columns to be displayed on this row. |
getColumnsDiff | |
---|---|
Returns the difference between the current columns and the columns from the last diff, or null if there is no difference. | |
Returns | |
IterableChanges<any> | null |
CdkCellOutletRowContext
Context provided to the row cells
Name | Description |
---|---|
| Data for the row that this cell is located within. |
| Length of the number of total rows. |
| True if this cell is contained in a row with an even-numbered index. |
| True if this cell is contained in the first row. |
| Index location of the row that this cell is located within. |
| True if this cell is contained in the last row. |
| True if this cell is contained in a row with an odd-numbered index. |