BernhardtD / vue-sorted-table

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

Feature(s) Request #2

Closed pimboden closed 4 years ago

pimboden commented 4 years ago

Hello Very nice component! It would be nice, if it could be possible to have a custom sope for the sort icons. I'd rather have only 1 icon and show the icon just transformed by 180 deg. so I could add some transition to it

Another thing , it would be cool to have is, if i could for certain columns override the standard sorter. For example I need to sort a column of colors by its value (I.E red ->blue->green-> yellow) and not by its name. Or if I have enumerations that come from the server as Ids and Im showing the friendly name. This is not so critical, because of course I could just map my array of values and add a Column with that information.

BernhardtD commented 4 years ago

Thank you for your request. Adding a slot to use custom sort icons should be no problem. I'll add this with the next release.

The default sort function does not sort by the given value of property name on sort-link. The name is the object key name of the value which should be sorted, e.g.:

values: [
  { name: "Black", id: 2, color: '#000000' },
  { name: "Red", id: 1, color: '#ff0000' },
  { name: "Blue", id: 3, color: '#0000ff' }
]

The object key name to sort the array could be name, id or color. Just extend the values array by additional color codes or id and specify the object key on the sort-link name property.

BernhardtD commented 4 years ago

I added an example how to use the custom icon slot on codesandbox.io