event listener for sorting
Is there a way to add event listener to sorting in the table column headers. For example, if I click on the table header it sorts it in "asc" or "desc" order, but what I want is when user clicks on it, I should be able to get the state of sorting and then store it in react state so that even if user moves to another page and returns back, his sorting state should be same which he selected previously instead of sorting again. Please let me know for any doubts.
did you try this? onOrderChange(orderedColumnId, orderDirection)
did you try this? onOrderChange(orderedColumnId, orderDirection)
Hi thankyou for you reply. I have tried onOrderChange(orderedColumnId, orderDirection), here the issue is, sometimes orderedColumnId goes to -1 and I am not sure why and my second issue is even if I get column Id how do I set "asc" or "desc" on a specific column which user has selected even if page is refreshed.
Ordered Column id will be -1 if no sorting is taking place and the data is not sorted . You need to persist the current sorting for example adding it to the URL and set the default sorting of the columns of the URL has the appropriate parameters on render.
this could help options: { thirdSortClick: false }
Ordered Column id will be -1 if no sorting is taking place and the data is not sorted . You need to persist the current sorting for example adding it to the URL and set the default sorting of the columns of the URL has the appropriate parameters on render.
I understand, Thankyou
this could help options: { thirdSortClick: false }
That worked, thankyou
Looks like this has been resolved. Feel free to reopen if it's not resolved.