Child row doesn't close in the example

Child row doesn't close in the example

FicosFicos Posts: 65Questions: 19Answers: 0

Link to test case:

// Add event listener for opening and closing details
    $('#example tbody').on('click', 'td.dt-control', function () {
        var tr = $(this).closest('tr');
        var row = table.row( tr );
        if ( row.child.isShown() ) {
            // This row is already open - close it
        else {
            // Open this row
            row.child( format( ).show();
    } );

As the example says: an open row should be closed when another row is opened, but that does not work.
How can I fix this?


  • kthorngrenkthorngren Posts: 18,553Questions: 25Answers: 4,401

    The example doesn't say that the other rows will be closed. This is from the example:

    to first check if a row is already displayed, and if so hide it (row().child.hide()), otherwise show it (row()

    See this example form this thread to see how to close all open rows. It uses a button click but you can place the code in the above click hander.


Sign In or Register to comment.