Can you add Generic Type into QTableProps? #17919
-
So I have a table and rows are quite complex, not just a simple object. So I would like to do:
But I don't see that QTableProps is generic. I found this Issue. But I don't quite understand the solution to the problem. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
First of all, You can use something like this: <template>
...
<template #body="scope: BodyScope">
</template>
...
</template>
<script lang="ts" setup>
import { QTableSlots } from 'quasar';
interface BodyScope<T = any> extends Parameters<QTableSlots["body"]>[0] {
row: T;
}
</script> We are planning to add generic to all component types: #16935 |
Beta Was this translation helpful? Give feedback.
First of all,
props
in#body="props"
is just a naming choice. It doesn't actually contain the columns. So,QTableProps
is not the correct type to use there.You can use something like this:
We are planning to add generic to all component types: #16935
So, when that is done, you will be able to automatically get the correct value with just
#body="scope"
, without doing anything extra. But, for now, you can use the way I provided above.