DataTable sortable works on normal column with field attribute, but does not work on template column without field attribute.
Is there any way I can choose to sort on template column as follows?
<Column :sortable="true">
<template #body="slotProps">
{{ calculateScore(slotProps.data.items) }}
</template>
</Column>
DataTable sortable does not work on template column
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
It is expected, column has no idea what to use for sorting. One solution is adding a field to your row data like calculated items. Templating is useful for adding custom content but table needs metadata to use in sorting like a field.
Other alternative is custom sorting which will be in 2.0.0-final where you can implement your own sorting.
Code: Select all
<Column :sortable="true" field="calculatedScore"></Column>
Code: Select all
rowData.calculatedScore = this.calculateScore(rowData.items)
-
- Information
-
Who is online
Users browsing this forum: No registered users and 12 guests