How to close/remove all opened child rows on table resize ?

How to close/remove all opened child rows on table resize ?

vv7v7vv7v7 Posts: 9Questions: 3Answers: 0
edited October 2017 in Free community support

Dear Reader,

Is it possible to close/remove all opened child rows in all tables and how ?

This one doesn't work:

    table_api.on( 'responsive-resize', function ( e, datatable, columns ) {
      $( "#" + e.target.id + " tbody tr.opened" ).each( function ( index, value ) {
        var op_row = table_api.row( value );
        if ( op_row.child.isShown( ) ) op_row.child.remove( );
        op_row.removeClass( 'opened' );
      });
    });

Btw tables are generated like this

Best regards,
vv7v7

Answers

  • allanallan Posts: 63,468Questions: 1Answers: 10,466 Site admin

    I'd be tempted to try activating the click event on the element rather than using the API directly for this one.

    $( "#" + e.target.id + " tbody tr.opened td:first-child" ).click();
    

    perhaps?

    Allan

This discussion has been closed.