DataTables / Responsive

Responsive extension for DataTables, providing support for complex tables on all device screen sizes
Other
149 stars 88 forks source link

Question about sorting DataTables while using Responsive plugin #136

Open pczarn2 opened 1 month ago

pczarn2 commented 1 month ago

Not an issue but a question. When responsive plugin is used and DataTable has sorting columns activated, the columns that are collapsed to the child rows cannot be clicked on to re-sort the data table by those columns. Any suggestions on how to deal with this? The idea is to give the users access to sort by all columns and not only by the un-collapsed columns they see when responsive layout is activated by the user (either by zooming in or using mobile browsers). I was thinking that maybe have a dropdown box before DataTable with search options that list all of the columns that can be used for sorting, but not sure if that would be possible to do or not?

AllanJard commented 1 month ago

I was thinking that maybe have a dropdown box before DataTable with search options that list all of the columns that can be used for sorting, but not sure if that would be possible to do or not?

I think that's a good option and one that I should look at adding as a core part of the Buttons. I've made a note of that in my tracker. It is certainly possible, and would be similar to the column visibility button.

pczarn2 commented 1 month ago

Thank you Allan, this would be great addition. I'm looking forward to seeing it in the future.

mscdex commented 4 days ago

For what it's worth how I've handled this in the past is by using a custom child rows renderer. This allows me to add the same ascending/descending indicators and you can tap/click on the column name to change the sorting just as you would normally. I also used some CSS trickery to avoid a lot of potentially heavy javascript code to get everything looking correct.

If anyone is interested I can try to extract the necessary bits into an independent example.

pczarn2 commented 3 days ago

@mscdex If you could share the example that would be fantastic!