vincjo / datatables

A toolkit for creating datatable components with Svelte
https://vincjo.fr/datatables
MIT License
372 stars 15 forks source link

Sorting and filtering does not work for datetime columns #27

Closed ak4zh closed 1 year ago

vincjo commented 1 year ago

Only for JSON types (string, number, boolean, array, object). There is no standard for date/time format in JSON

But you can use a callback fn :

<Th {handler} sortBy={(row) => row.myDate.toISOString()}>Date</Th>

<ThFilter {handler} filterBy={(row) => row.myDate.toISOString()}/>

Outside of components :

const handler = new DataHandler(data)

handler.sort( (row) => row.myDate.toISOString() )
handler.filter( '2023', (row) => row.myDate.toISOString() )