primevue icon indicating copy to clipboard operation
primevue copied to clipboard

Datatable: Date sorting is working only on it own with multiple sorting

Open alpiua opened this issue 1 year ago • 2 comments

Describe the bug

When I try to sort on multiple columns, the column in Date format after been selected, prevents any other column from being sorted.

Reproducer

https://stackblitz.com/edit/datesortingbug?file=src%2FApp.vue

PrimeVue version

3.5.0

Vue version

3.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

  1. Create datatable component with multiple sorting columns
  2. Select column with Date type in it
  3. See that sorting in other columns is not working at all

Expected behavior

I expect to see a working sorting for any column in any order chosen.

alpiua avatar May 28 '24 01:05 alpiua

Add .getTime() to your dates to use unix timestamp and it will work.

const dummyData = [
  {
    date: new Date(2023, 2, 10).getTime(), // May 15, 2023
[...]

PrimeVues datatable can't compare objects when multisorting, hence you have to provide a string.

riskysciolism avatar Aug 28 '24 15:08 riskysciolism

Thank you, now I get it. I believe the documentation would benefit from including this.

OleksiiPylypcuk-cnic avatar Aug 28 '24 18:08 OleksiiPylypcuk-cnic