-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Added support for table multi-column sorting #946
Conversation
My initial thought: This is a lot of complexity (the behavior you're describing) to be built into I believe the only thing preventing you from implementing it that way is the I'm thinking of an API like this: <Table
{...props}
sort={createComplexSort(yourSimpleSortFunction)}
/> PS. I think your table has some typos in it, wrt what's being shift or control clicked. Either that or I'm just misunderstanding some of the rows. For example, how does shift-clicking Second end up adding First to the sort? And how does control-clicking Second remove First? |
I am not comfortable with changing the current default behavior of |
i will create new PR (dont have permission to open this one) - #957
Thats would allow consumer to set sort by multiple columns, but table would render only for first one...
yea, these are copy-paste bugs ... fixed |
Yes, thanks! That's what I meant (a new PR) 😄 My main goal is to not add this complexity into
I'm not sure I understand your wording here. I think you may be saying that because |
Okay ... i can do that ... but look how i did it in that second PR first (all multi-sort related code is enabled by single prop) - maily for another code suggestions i could use ...
yea .. that was in my thought ... and my wording is wierd, because english is not my first language :( |
looked tru the code and im not sure that composition is right way for this - i modified 'private' method _createHeader and added another 'private' method _handleMultiSortColumnClick to handle multi-sort. i could create HOC which would override _createHeader but that is just wrong - HOC becomes aware about 'private' method of Table. Any ideas how to do this? |
"Composition" is kind of a broad term. What I suggested was a utility function to create a complex |
technically i can write sort function, that would sort by multiple columns right now - but table wouldn't know about it and didnt show correct sort indicators ... Writing this gived me an idea:
from external perspective behavior of Table component wouldn't change ... |
Which is why I also suggested updating the |
Modified how
sort
method is called when used clicks on column header:if sorted only by one column return single value instead of array (backward comp.)
preview: (action shows how to get from state in one row above)
EDIT: Fixed copy-paste bugs in table