table.responsive.hasHidden() gives "Cannot read property 'hasHidden' of undefined"

table.responsive.hasHidden() gives "Cannot read property 'hasHidden' of undefined"

darrenmdarrenm Posts: 29Questions: 11Answers: 0

I'm trying to perform some functions on page load if responsive has hidden any columns. I think I can use hasHidden() for this, but when I try to check it in my code I get the "Cannot read property 'hasHidden' of undefined" error.

All the responsive functions are working fine.

I am trying to check hasHidden in the initComplete function of the DataTable call.

My code:

$("#sale").DataTable({
    pageLength: 25,
    responsive: true,
    stateSave: true,

    // etc...

    initComplete: function () {

        if ($("#sale").responsive.hasHidden()) {
            $("#filterpanel").show();
        }
        else {
            $("#filterpanel").hide();
        }
    }
});

Is this a timing issue or am I doing something else wrong?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,207Questions: 1Answers: 2,592
    Answer ✓

    Hi @darrenm ,

    You need to get into the API - so either $("#sale").DataTable().responsive.hasHidden() or this.api().responsive.hasHidden() - see example here,

    Cheers,

    Colin

  • darrenmdarrenm Posts: 29Questions: 11Answers: 0

    Damn I thought I tried that, but obviously not! Perfect, thank you.

This discussion has been closed.