vincjo / datatables

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

Filter and sorting with nested array in object #98

Closed azern32 closed 3 months ago

azern32 commented 4 months ago

I have data where the format goes like this

result : [
    0: {
      key1 : value1,
      ....,
      keyN : [
         0: {
              nestedN : valueN
         },
         1: {
              nestedN : valueN
         },
     ]
    },
    1: ...
]

The very top array will be the rows

How can I filter and sort by that "nestedN" ?

I tried using

{handler} orderBy={(row) => row.keyN.nestedN} 

but it failed to do so. I figure this must be because the data to filter were inside an array. Yet, all the examples I see using just object.

Any help?

vincjo commented 3 months ago

Just add to deep copy the input instead of shallow copy. Added to 2.0