-
Notifications
You must be signed in to change notification settings - Fork 934
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
sortDirection cannot be applied for more than one column. #966
Comments
In order to apply a new sort direction, you have to remove one of the existing sort directions. Sorting along one than one column at once is not possible, as I understand it (not possible even in theory). |
Hi @gabrielliwerant , seems pretty redundant he's creating new issues for the basically same issue, but I'm not sure if I'm understanding correctly. I understand we have to keep the values in the state that we want to track while using example:
which in the console I get a response like this: But in order to apply whether a column is ascending or descending, we have to supply the but when we want to update the sortDirection with the value (the order value) we get after fetching the data, like @T-pirithiviraj stated, it gives an error that sortDirection cannot be applied to multiple columns. If this is the case, where I cannot supply sortDirection option to the columns (more than one), how do I approach sorting for individual columns? They currently all sort individually but it does not toggle from 'desc' to 'asc' because I cannot update this value to the column. Sorry for the lengthy question. Thank you for this wonderful library. |
Thanks @danielbyun , That was my exact question too. We are doing set state with the direction but how to update that sortDirection in individual column if it is sorry for the repeated same issue. I am not getting clear picture on server side how to use? since I am new to react and this library. |
|
Unlike the previous |
Hello, Here is a small example of what I'm trying to do. I've actually pulled this from @gabrielliwerant 's example for issue #468 . https://codesandbox.io/s/muidatatables-custom-toolbar-tl55g As you can see in the console, If we just use your example, the 'Name' column sorts fine (whether it actually sorts perfectly, doesn't matter). How would I approach filtering the 'Title' column as well, if needed, filtering all of the columns (individually)? *note: not trying to apply multiple sorting, at least not yet. I keep track of nameColumnSortDirection in my state and assign that to Thank you for your guidance. |
Hello @danielbyun. Firstly, you'd have to track each column sort direction separately. As of now, if you use the same (psuedocode)
Then you can try to set it accordingly so that only one is sorted at a time: (psuedocode)
|
Thank you for your response and your pseudocode. The root of the question is that when |
Thanks for the response @gabrielliwerant . |
https://codesandbox.io/s/muidatatables-custom-toolbar-f2uc1 The |
@T-pirithiviraj and @danielbyun You cannot set sort direction for more than one column. Only one column can be sorted at a time. That's just what is physically possible, it's not a library constraint (though the library prevents it from entering into a wonky state by cutting off the attempt and displaying the message so that you know to change your code). |
Are you saying that this is not working for |
Not being able to set more than one sort direction at once is intentional and won't be fixed, however, |
yeah @gabrielliwerant . This is not working for none also.If you set none for other columns, the console error is there. |
Huh. Then I definitely am understanding the implementation of Hey @T-pirithiviraj , do you mind making a small example on codeSandBox on how you're implementing the sortDirection so that each column can be sorted individually?
Seems like I'm not doing it correctly as @gabrielliwerant stated. |
Hey @gabrielliwerant , thank you and great work! I finally understand how it works now, and it works wonderfully. I might make a small little example to show how it works for future reference because I have referred to many examples that so many users here have contributed. Thanks again for the library! Also thanks to @T-pirithiviraj for creating three issues for this sorting problem haha. |
Glad to hear it @danielbyun! Any interest in adding a serverside sorting example to this repo? I would be glad to consider adding it. |
Sure thing, @gabrielliwerant ! |
If we apply sortDirection for more than one column, it is throwing an error.
Expected Behavior
sortDirection should work for all the column in case we update the state.
Current Behavior
Open the console, apply sort direction for more than one column it is throwing an error as sortDirection can be applied for only one column.
Steps to Reproduce (for bugs)
Sample code:
The text was updated successfully, but these errors were encountered: