primevue
primevue copied to clipboard
Datatable: Date sorting is working only on it own with multiple sorting
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
- Create datatable component with multiple sorting columns
- Select column with Date type in it
- 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.
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.
Thank you, now I get it. I believe the documentation would benefit from including this.