responsive.recalc() undefined

responsive.recalc() undefined

koskos Posts: 5Questions: 2Answers: 0

Hi,
first of all thanks for an awesome plugin :) I'm currently working on a website built with bootstrap and for tables I'm using the responsive extension (all latest versions).

So my problem occurs because I have some tables in tabs, which are hidden on datatable init, so the layout is broken on show. So to correct this I tried using responsive.recalc() like it says in the reference, but nothing happens and if I debug the code, it says that the function is undefined.

My code:

$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {

$('.data-table:visible').each( function(e) {

$(this).DataTable().columns.adjust().responsive.recalc();

}) })

DataTables debug if needed - http://debug.datatables.net/aceley

What am I doing wrong?

Thank you for any help.

This question has an accepted answers - jump to answer

Answers

  • JamaurJamaur Posts: 87Questions: 10Answers: 0

    Could you try responsive.recalc() without columns.adjust() and see if it works?

    $(this).DataTable().responsive.recalc();
    
  • koskos Posts: 5Questions: 2Answers: 0

    Tried it, no difference, it's still undefined. I also tried 1.0.2-dev version and it also doesn't work.

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin

    Please link to a test case showing the issue. Here is a trivial test case which shows it working: http://live.datatables.net/walocode/1/edit .

    Allan

  • koskos Posts: 5Questions: 2Answers: 0

    Hey allan,
    I've made a quick mock up here - http://live.datatables.net/rerimoxo/1/edit

    So on the page load, the table in tab 2 has those expand buttons, despite not having any hidden columns. If you then resize the window until the responsive is actually needed and then back, it fixes it self.

    The tab shown event is definitely triggering and table selector is working (id in alert).

    Any ideas?

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin

    Super - thanks for the test case. That look very much like a bug to me.

    Allan

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    Answer ✓

    I've just committed a fix for this and the test case is working now. Thanks for that!

    Allan

  • koskos Posts: 5Questions: 2Answers: 0

    Oh wow, thanks for a quick fix allan :) That fixed the problem.

This discussion has been closed.