user1755189
user1755189

Reputation: 503

Type script definition for rows and columns of Quasar QTable

I was wondering if there is a typescript definition for rows and columns of Qtable ? Thanks in advance marnold

Upvotes: 7

Views: 3742

Answers (2)

KorbenDose
KorbenDose

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

M.A.T
M.A.T

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

Related Questions