vincjo / datatables

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

[Bug] Sorting isn't applied when data is refreshed #18

Closed mattpurlandncc closed 1 year ago

mattpurlandncc commented 1 year ago

Even though getSorted() is unchanged and returns the sorting object, the rows aren't sorted when the data is refresh

vincjo commented 1 year ago

Does it occurs when you use setRows(data) ? I'll check once I'm done with the reactivity example

If the user modifies an entry, I would prefer the table to remain structured after invalidating/reloading the data

mattpurlandncc commented 1 year ago

@vincjo it may just be a result of my stack, I'm not sure. I'm using Svelte with Laravel and Inertia. But when the underlying data is changed I'm doing the following:

$: if(underlyingData) {
    // Underlying data has been refreshed via an Inertia request and has updated the page prop. Set the row data
    handler.setRows([...underlyingData]);
}

Both filters and search are reapplied as expected, but sorting isn't

vincjo commented 1 year ago

I reproduced the same bug with my stack. I'll make a quick fix, thx for point it out

mattpurlandncc commented 1 year ago

No problem, glad I could help

vincjo commented 1 year ago

Problem solved with 1.4.0