Closed ethanfox closed 1 year ago
For whatever reason, there is no error now. However, I am having trouble showing the nested properties: "permissions" in the table. It is currently showing as [object Object]
Hey @ethanfox, by default each table cell simply renders the data property as is.
<td>
{/* whatever the value of `item.permissions` */}
</td>
Since permissions
is an array object, it will show up as [object Object]
.
To customize the rendering behaviour, you can look at cell
of the column definition.
<script>
const table = createTable(roleArray);
const columns = table.createColumns([
table.column({
header: 'Name',
accessor: 'name',
}),
table.column({
header: 'Permissions',
accessor: 'permissions',
cell: ({ value }) => JSON.stringify(value), // however you want to customize the row
}),
]);
const {
headerRows,
rows,
tableAttrs,
tableBodyAttrs,
} = table.createViewModel(columns);
</script>
Although, take note that each data item only shows up as one row. If you want multiple rows instead for each property, take a look at addSubRows
and addExpandedRows
.
Note that you'll have to modify the data format a bit to make it work though, but I can work on a more detailed example if you have any further troubles
Let me know if there's any further issues! @ethanfox
I'm using Supabase to query data to load into a table but I keep getting this error: Cannot read properties of undefined (reading 'map')
Data Model
Code