Skip to content

Commit 3c34a6e

Browse files
committed
on click handler for cell
1 parent 805ca2e commit 3c34a6e

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

projects/angular-datatable-advanced-examples/src/app/app.component.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,21 @@ export class AppComponent {
3939
filterInPromise: this.loadRecordClass()
4040
}, {
4141
columnKey: 'geolocation.type',
42-
columnName: 'Geolocation type'
42+
columnName: 'Geolocation type',
43+
onClick: row => {
44+
console.log('Geolocation', row);
45+
}
4346
}, {
4447
columnKey: 'coords',
4548
columnName: 'Coordinates',
4649
cellRender: (row) => row.geolocation && row.geolocation.coordinates
4750
? `LNG: ${row.geolocation.coordinates[0]}, LAT: ${row.geolocation.coordinates[1]}`
4851
: '-',
4952
sortable: true,
50-
filterable: true
53+
filterable: true,
54+
onClick: row => {
55+
console.log('coords', row);
56+
}
5157
}, {
5258
columnKey: 'test',
5359
columnName: 'Test date time picker',

projects/angular-datatable-advanced/src/lib/angular-datatable-advanced.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<span mat-sort-header class="ada-sort" [disabled]="!column.column.sortable"></span>
1313
<ada-filter [column]="column" [filterUpdateSubject]="filterUpdateSubject" *ngIf="column.column.filterable"></ada-filter>
1414
</mat-header-cell>
15-
<mat-cell class="ada-td" *matCellDef="let row" [innerHTML]="renderCell(row, column.column)"></mat-cell>
15+
<mat-cell class="ada-td" *matCellDef="let row" [innerHTML]="renderCell(row, column.column)" (click)="column.column.onClick && column.column.onClick(row)"></mat-cell>
1616
</ng-container>
1717

1818
<mat-header-row class="ada-header-row" *matHeaderRowDef="getColumns()"></mat-header-row>

projects/angular-datatable-advanced/src/lib/model/column.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class Column {
1212
filterIn?: Array<FilterIn> = [];
1313
filterInPromise?: Observable<Array<FilterIn>> = null;
1414
filterDateOptions?: FlatpickrDefaultsInterface;
15+
onClick?: (row: any) => void;
1516
}
1617

1718
export class ExtendedColumn {

0 commit comments

Comments
 (0)