Skip to content
This repository has been archived by the owner on Jan 15, 2022. It is now read-only.

Multi-column sorting #376

Open
ssorallen opened this issue May 25, 2017 · 0 comments
Open

Multi-column sorting #376

ssorallen opened this issue May 25, 2017 · 0 comments

Comments

@ssorallen
Copy link

ssorallen commented May 25, 2017

It would be nice to be able to sort by multiple columns. If two rows are equal for a given column, they will continue attempting further sorters until all Sorters are exhausted or an order is found.

The defaultSort prop could take an Array<Sorter>.

<Table className="table" id="table" data={[
    { Name: 'Lee Salminen', Age: '23', Position: 'Programmer'},
    { Name: 'Griffin Smith', Age: '18', Position: 'Engineer'},
    { Name: 'Ian Zhang', Age: '28', Position: 'Developer'},
    { Name: 'Lou Malnati', Age: '28', Position: 'Programmer'}
]}
sortable={[
    'Age',
    'Position'
]}
defaultSort={[{column: 'Age', direction: 'desc'}, {column: 'Position', direction: 'asc']}
defaultSortDescending

onSort could return an Array<Sorter> if multiple columns are being sorted.

[
  {
    column: 'Name',
    direction: -1
  },
  {
    column: 'Age',
    direction: 1
  }
]

The interaction for clicking columns would need some design consideration.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant