vincjo / datatables

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

Sorting with Nested Objects #59

Closed MrVauxs closed 10 months ago

MrVauxs commented 10 months ago

Hi, is there a way to sort using a nested object, like name.primary? Alternatively, it would be nice to be able to provide your own sorting function.

vincjo commented 10 months ago

Hi,

There is a way:

handler.sort( (row) => row.name.primary )

Using Th component:

<Th {handler} orderBy={(row) => row.name.primary}>
    Primary
</Th>

Thx for your suggestion, will think about it

vincjo commented 10 months ago

At the moment I don't figure out what problem a custom sorting function could solve. if you have more ideas about it, don't hesitate to post a new issue/suggestion