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

Programmatically set sorting Column and Direction #761

Closed
Olliebaba opened this issue Apr 24, 2017 · 8 comments
Closed

Programmatically set sorting Column and Direction #761

Olliebaba opened this issue Apr 24, 2017 · 8 comments

Comments

@Olliebaba
Copy link

Olliebaba commented Apr 24, 2017

WHICH VERSION OF REACT ARE YOU USING?

Officially Supported:
[ ] v0.14.x
Community Supported:
[X ] v15.0.x

WHICH BROWSER ARE YOU USING?

Officially Supported:
[ ] IE 9 / IE 10 / IE 11
[ ] Edge
[X ] Chrome
Should work:
[ ] Firefox
[ ] Safari

I'm submitting a ... (check one with "x")

[ ] bug report
[ X] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/adazzle/react-data-grid/blob/master/CONTRIBUTING.md

Current behavior
Currently a user must click a column's header to trigger the handleSort method. (PR #649 addresses how to set initial sort through getInitialState)

Expected/desired behavior
Create external access to trigger sorting.

What is the motivation / use case for changing the behavior?
I would like to have access to this method so that I can set the column caret from a parent container in place of forcing CSS styles to show which column the data is sorted by.

I have a form which searches for contacts via various fields. I would like to sort the data based on which input fields have value. Since I have no means of triggering handleChange, the only way I am able to display sorting column and direction is by having additional checks on the parent's state and forcing CSS styles for the carets.

@Olliebaba
Copy link
Author

After thinking about this for a while, I realized it might just be better to simply allow to take sorting Column and Direction as props. (Not just for initialization as in PR #649 )

@jrnail23
Copy link

@Olliebaba, we're looking for generally the same thing, except we need to do multi-column sorting (i.e., sort by lastName ASC then by firstName ASC then by birthDate DESC)

@reno004
Copy link

reno004 commented Sep 17, 2017

@Olliebaba @jrnail123
i need to do multi-column sorting..can you please post how to accomplish it

@Olliebaba
Copy link
Author

@jrnail23 and @reno004 - I decided to write my own table plugin for the project i'm working on because requirements kept on drifting further from how react-data-grid operates. As far as multi column sorting, that would be in your .sort() method itself. You will need to have nested ifs to do so. Example

@reno004
Copy link

reno004 commented Sep 29, 2017

@Olliebaba sorry for being naive....how do we show the multiple columns as sorted in the grid.

Thanks in advance

@Olliebaba
Copy link
Author

@reno004 - when you say multi-column sorting, how do you mean? If you post your question with more detail on stack overflow, I can try my best to help you but this isn't the correct platform to get into such details. Post on stack overflow and then reply with the link please.

@amanmahajan7
Copy link
Contributor

This feature has been merger #649

@milkersarac
Copy link

I need this merger, when will you publish next npm package containing this merge? Thanks.

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

No branches or pull requests

5 participants