carbon-design-system / carbon

A design system built by IBM
https://www.carbondesignsystem.com
Apache License 2.0
7.85k stars 1.81k forks source link

[Feature Request]: Is it possible to add customized rule for sort in DataTable #12073

Closed GraceeFlower closed 2 years ago

GraceeFlower commented 2 years ago

Summary

Hi team, I found DataTable in carbon-components-svelte can sort some column by customized rule like:

const headers = [
 {
    key: "expireDate",
    value: "Expire date",
    display: (date: string) => new Date(date).toLocaleString(),
    sort: (a: string, b: string) => new Date(a) - new Date(b),
  }
]

Is there any way that I can use like this? Since I only found sortBy and sortRows, THX!

Justification

I wanna implement that sort one role in my customized rule. Like some tasks status, ordering by the first character doesn't make sense to it.

Screenshots

N/A

Desired UX and success metrics

No response

Required functionality

No response

Specific timeline issues / requests

No response

Your team

N/A

Available extra resources

No response

Code of Conduct

tay1orjones commented 2 years ago

@GraceeFlower Thanks for bringing this up! There's not yet a way to pass in an initial sort for the table. There's an open issue for it though with some ideas of an implementation if you're interested in contributing, https://github.com/carbon-design-system/carbon/issues/11580

tay1orjones commented 2 years ago

Duplicate of https://github.com/carbon-design-system/carbon/issues/11580