Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export class DataTableBodyComponent<TRow extends Row = any> implements OnInit, O
readonly groupHeader = input<DatatableGroupHeaderDirective>();
readonly selectCheck = input<(value: TRow, index: number, array: TRow[]) => boolean>();
readonly displayCheck = input<(row: TRow, column: TableColumnInternal, value?: any) => boolean>();
readonly trackByProp = input<string>();
readonly trackByProp = input<keyof TRow>();
readonly rowClass = input<(row: TRow) => string | Record<string, boolean>>();
readonly groupedRows = input<Group<TRow>[]>();
// TODO: Find a better way to handle default expansion state with signal input
Expand Down Expand Up @@ -394,8 +394,8 @@ export class DataTableBodyComponent<TRow extends Row = any> implements OnInit, O
return index;
}
const trackByProp = this.trackByProp();
if (trackByProp && row) {
return (row as any)[trackByProp];
if (trackByProp && row && this.isRow(row)) {
return row[trackByProp];
} else if (row && this.isGroup(row)) {
return row.key ?? index;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export class DatatableComponent<TRow extends Row = any>
* Property to which you can use for custom tracking of rows.
* Example: 'name'
*/
@Input() trackByProp?: string;
@Input() trackByProp?: keyof TRow;

/**
* Property to which you can use for determining select all
Expand Down
Loading