How to implement custom sort button #2951
-
So I have a fairly straight forward drop down menu I'd like to use to replace the native "click to sort" functionality. I've tried several ways to implement it, but I've gotten infinite loops, or errors such as "toggleSortBy is not a function". The method that seems most likely to work is something like the one in this example: I've stripped down the function to an absolute barebones version below. Can someone help me implement this into a basic table?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I found a solution. I was trying to keep the function outside of the actual table component function to keep it slim and pass the column in as a prop, but I think there was more instance properties required to make that work? Instead I've just put the dropDownHeader function directly inside the useTable function and directly access the main table's toggleSortBy function. Works great.
and then I call the dropdown function in the table body as below:
|
Beta Was this translation helpful? Give feedback.
I found a solution. I was trying to keep the function outside of the actual table component function to keep it slim and pass the column in as a prop, but I think there was more instance properties required to make that work? Instead I've just put the dropDownHeader function directly inside the useTable function and directly access the main table's toggleSortBy function. Works great.
and then I call the dropdown function in the table body as below: