Responsive not working and I'm out of ideas
Responsive not working and I'm out of ideas
Link to test case: http://clientes.warma.pe/agendosalud/admin/appointments/ (user/password: test/test)
Debugger code (debug.datatables.net): I get this error when trying to upload it: Uncaught TypeError: table.oInstance.fnGetData is not a function
Error messages shown: No error messages when loading or using the table, everything else seems to work without issues.
Description of problem:
I've tried using both the data-priority attributes and the columnDef options, but I still can't get the Responsive to work.
I have updated to the latest version of DataTables both with CDN and local, also minimized and not, and with the CDN I tried with compiled and without.
I have also tried the following:
Adding this code: .DataTable().columns.adjust().responsive.recalc();
Adding table-layout: fixed; to the body of the page.
I've run out of ideas, I'm not really sure what could be causing this to not work. The only thing I could think of is that the parent container has display: flex; but that seems like a stretch.
The data is being pulled from an Ajax.
Any and all help will be greatly appreciated it!!!
Answers
The js code (maybe a bit extra convoluted, it's because we're in the process of building a CMS):
Html code (after getting the data via Ajax):
Thanks for the link! I agree - something isn't working there!
Could you load the non
.min
version of both DataTables and Responsive for me please? I'll trace it through to see what is going wrong.Thanks,
Allan
@allan Thank you for the quick reply!
I made the change, it's loading the non-.min files now.
Magic - thank you. It is the flex box. It auto grows to allow the content to fit into the space, if the content is too wide.
To fix, in this case, add
overflow: hidden;'
to yourmain#sakura main#main
style.Allan
That did it! Thank you so much!
Quick question, I just added a min-width to a column and some nowrap to others, since they were only hiding when they became absolutely tiny. However, now the table overflows the container before hiding the columns... any ideas?
Sorry for taking so much of your time!
I'm not actually seeing how you are doing the min-width? However, the issue is that the temporary table that Responsive constructs to see what can fit into the space available does not have that min-width also applied, thus the calculations are performed on a collapsed size, and it thinks it can fit in more than it can.
How are you doing the min-width? I wonder if we can apply that to the temp table as well somehow.
Allan
Oh that's actually very interesting.
So, most columns have text-wrap: nowrap; that's applied to th.dt-medium and td.dt-medium, which is most of the columns in this case.
min-width: 200px; and text-wrap: nowrap; is applied to th.dt-title and td.dt-title (first column)
Finally, the last column has a min-width: 75px;
Hey @allan, any luck with this? I've been trying on my end without any luck.
@Fredtholomew
We got the same issue.
I wouldn't use DataTables in production if you need it in responsive way. It's horrible and they not support it in a good way.
Its sad in 2024.