import { Component } from '@angular/core';
import { Datagrid, ColumnDef } from '@angular-bootstrap/ngbootstrap';
@Component({
imports: [Datagrid],
template: `
<ngb-datagrid
[columns]="columns"
[data]="orders"
[rowClass]="rowClass"
[highlightedIndex]="highlightedIndex"
[highlightRowKey]="'id'"
[highlightColKey]="'field'"
></ngb-datagrid>
`,
})
export class RowHighlightDemo {
columns: ColumnDef<OrderRow>[] = [
{ field: 'orderNumber', header: 'Order #', width: 150 },
{ field: 'status', header: 'Status', width: 160 },
{ field: 'priority', header: 'Priority', width: 140 },
];
rowClass = (row: OrderRow) => ({
'orders-row-review': row.status === 'Pending',
'orders-row-attention': row.priority === 'High',
});
highlightedIndex = [
{ row: 3 },
{ row: 3, columnKey: 'status' },
{ row: 8, columnKey: 'priority' },
];
}