issue when Api responsive.recalc() jquery load indeterminate numbers of responsives tables
issue when Api responsive.recalc() jquery load indeterminate numbers of responsives tables
I have a very strange issue, i'm able to use the great datatable plugin in many places.
But when i load the tables trought Jquery.load() ajax function the responsive characteristic do not work correctly until manualy change the size of the window.
I make a research and I can not make it work responsive.recalc() and columns.adjust().
This is my load function that bring me the tables when change an select input :
```
$('#idPresupuesto').change(function(event) {
$('.table1').load('actions/manyTablesLoads.php?id='+$('#id').val(), function () {
var table = $('table.display').DataTable({responsive: true}).responsive.recalc();
$.fn.dataTable.tables( { visible: true, api: true } ).columns.adjust();
$('#preloader').fadeOut('slow');
});
```
What i make it wrong?
Best Regards!
This question has an accepted answers - jump to answer
Answers
You might need to add
.draw()
to yourcolumns.adjust()
line as shown in the docs.Kevin
Thanks Kevin, but the result is the same.
now change my code to :
With no success
Now i change to this, with succes on load the tables:
But now when open the collapse component aggregate other search bar to datatable
what's wrong?
It might also be worth adding a call to
responsive.rebuild()
before theresponsive.recalc()
. If that doesn't help, would you be able to link to the page so we can take a look.Hi colin i use the
responsive.rebuild
with no effects.After the Jquery.load(). i put this code but when open a collapsable the search input and the select show entries repeat when reopen a collapsible
Hi @fotosvinadelmar ,
Definitely something odd going on there - could you link to a test case that would demonstrate the problem?
Cheers,
Colin
Hi @colin , i made a reproduction in here,
Issue reproduction
Best regards.
i try this too with no success
https://datatables.net/manual/tech-notes/3#Meaning
Note: Datatable Debugger shows no errors.
Hi @fotosvinadelmar ,
If you open a second group (or reopen a single one), it tries to initialise all tables again and gives a page error.
This is initialising all tables - as all tables have class
.display
. You need to explicitly initialise the table being expanded, or, destroy all the current tables withdestroy()
before initialising the others.The responsive aspects are working as expected. They seem to be collapsed when the space is narrow, and not when wider. I'd say fix the reinitialising issue and see if it's behaving as expected then,
Cheers,
Colin
i made more coding for this and finally resolved the issue creating an empty table and destroing initialization if exists .
if ( $.fn.DataTable.isDataTable('#example') ) {
$('#example').DataTable().destroy();
}
And then filled with ajax json sourced and apply draw(true) and columns.adjust()
the source.php must be <?php echo json_encode($result); ?> as echoed result.
All this in the action of open a class named collapse to call an ajax every time when collapse is opened:
Thanks.