4

I am using a react component called react-data-table-component: https://github.com/jbetancur/react-data-table-component. The component is quite nice and feature rich and I am enjoying it so far. However, the client has requested a new feature whereby they can sort multiple columns at once (with a primary, secondary, tertiary sort, etc...). I do not see any mention of this functionality in the documentation. There is the ability to have custom sort functions per column, and I was hoping someone had an idea on how to implement multi column sorting with a mixture of custom sorting functions and perhaps clever usage of state. Can anyone help point me in the right direction?

1 Answer 1

2

I believe I found an answer. I am keeping the row data in state so that the grid renders whenever the data changes. I am going to use the onSort callback to keep a list of columns that are being sorted in state. Then I will use a custom sort function along with a multi sort function https://github.com/chuvikovd/multi-column-sort to achieve the desired result.

Sign up to request clarification or add additional context in comments.

1 Comment

Any chance after this while you would have a code for how you achieved this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.