Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table sortable #926

Closed
ssachtleben opened this issue Nov 23, 2016 · 10 comments
Closed

Table sortable #926

ssachtleben opened this issue Nov 23, 2016 · 10 comments

Comments

@ssachtleben
Copy link

Is sortable table somehow supported? There is no props for this so I tried to add it via the classNames:

<Table basic="very" className="sortable" padded stackable selectable>
....
    <Table.HeaderCell className="sorted descending">

The sort icon shows up but I cant click on the headers to change the sorting.

Anyone got an idea?

@ssachtleben ssachtleben changed the title Table Sorting Table sortable Nov 23, 2016
@keeslinp
Copy link
Contributor

As far as I know there isn't a baked-in feature for sorting a table (I could be wrong, there's a lot of stuff not in the docs). If I were in your position I would set a onClick event for the icon and just sort the data myself.

@levithomason
Copy link
Member

We do not currently support sortable tables, the only supported features are those which have props.

I believe the sorting should happen outside of the component, though, we should certainly provide the callbacks and props for enabling sorting. I'd gladly accept a PR that added this.

@ssachtleben
Copy link
Author

Ok thanks for the information. I will try to add the sorting myself and see if it fits into the lib.

@svrcekmichal
Copy link
Contributor

svrcekmichal commented Dec 29, 2016

@ssachtleben I believe it is impossible to make universal sorting for lib but I would add at least props which will activate sorting visually and let everyone implemenet what is needed. @levithomason I can make PR with changes:

  • add sortable to Table
  • add sorted="ascending" OR sorted="descending" to Table.HeaderCell

@belohlavek
Copy link

belohlavek commented Dec 29, 2016

FWIW, I'm working on a generic table component in my spare time (supports sorting among other features).
Current demo uses Semantic but it's designed to work with any UI library.
https://github.com/belohlavek/react-tabler

@svrcekmichal
Copy link
Contributor

svrcekmichal commented Dec 30, 2016

@belohlavek Yeah, that's what I believe is good. You can create custom data sort library and use semantic-ui-react for only visual sorting. Than you can implement what ever algorithm you want.

@levithomason
Copy link
Member

@levithomason I can make PR with changes:

  • add sortable to Table
  • add sorted="ascending" OR sorted="descending" to Table.HeaderCell

@svrcekmichal Precisely what I was thinking. Then, users can use the click handlers to sort their data and re-render the table.

@layershifter
Copy link
Member

Closing for housekeeping. Follow for #1195.

@levithomason
Copy link
Member

Note, this is available in 0.64.4 including typings. The doc site is only pending some examples.

@hopewise
Copy link

@ssachtleben did you have it working with the new release? can you share an example please

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

No branches or pull requests

7 participants