Reputation: 503
I was wondering if there is a typescript definition for rows and columns of Qtable ? Thanks in advance marnold
Upvotes: 7
Views: 3742
Reputation: 1273
If you want even more type safety, you can use QTableColumn
. It will type the field
and format
properties for columns correctly.
interface MyRow {
_id: string,
date: string,
foo: number
}
const rows: MyRow[] = [...]
const columns: QTableColumn<MyRow>[] = [{
field: 'foo', // typesafety here
format: (val, row) => ... // typesafety for row. It is of type MyRow
// ...
}]
Upvotes: 3
Reputation: 355
You can use QTableProps['columns']
and QTableProps['rows']
.
const columns: QTableProps['columns'] = [
{
name: 'number',
align: 'center',
label: 'ID',
field: 'number',
sortable: true,
}
];
const rows: QTableProps['rows'] = [
{ id: 1, name: 'Frozen Yogurt', calories: 159}
];
Upvotes: 18