BernhardtD / vue-sorted-table

A basic sorted table for Vue.js.
MIT License
33 stars 4 forks source link

Stable sort #17

Closed danielpanteleit closed 3 years ago

danielpanteleit commented 4 years ago

Hi,

is it possible to do a stable sort that honors previous sort operations? For example, for this table:

c1 c2
a 3
b 2
a 1
b 4

if I click on "c2" then on "c1", the table should look like this:

c1 c2
a 1
a 3
b 2
b 4

Thanks

BernhardtD commented 4 years ago

You should provide a custom sort function which stores previous sort requests. The SortedTable component provides the property onSort, which should be a callback to sort the given value array. The first argument of the custom sorting function is the selected property (e.g. 'id') and the second argument is the direction ('asc' or 'desc').

You recommend taking a look to other frameworks, like vuetify. Vuetify has a data table component which supports multi sorting.

projct1 commented 3 years ago

The SortedTable component provides the property onSort, which should be a callback to sort the given value array. The first argument of the custom sorting function is the selected property (e.g. 'id') and the second argument is the direction ('asc' or 'desc').

This is not working image image

BernhardtD commented 3 years ago

Your method sorting is defined, but does nothing. Take a look into the calling component. The first argument of the custom sorting function is the selected property (e.g. 'id') and the second argument is the direction ('asc' or 'desc'). You should sort the array of values by your own and pass the array to the sorted table component.

This issue is related to #25

projct1 commented 3 years ago

Thanks. But i moved to https://xaksis.github.io/vue-good-table/ and happy) Totally no pain now)