DataTable sortable does not work on template column

UI Components for Vue
Post Reply
findream
Posts: 6
Joined: 21 Feb 2020, 05:18

28 Apr 2020, 16:49

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>

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

17 May 2020, 16:31

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.

Code: Select all

<Column :sortable="true" field="calculatedScore"></Column>

Code: Select all

rowData.calculatedScore = this.calculateScore(rowData.items)
Other alternative is custom sorting which will be in 2.0.0-final where you can implement your own sorting.

Post Reply

Return to “PrimeVue”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 19 guests