Trying to open all child rows using drawCallBack

Trying to open all child rows using drawCallBack

kogokogo Posts: 1Questions: 1Answers: 0

I'm using the child rows example but I need to open all the child rows on load.

I've tried to do this by using the drawCallback method to render each child - not sure if I'm on the right track. It's failing at the point I'm trying to get a reference to the row, I think.

<script type="text/javascript">
/* Formatting function for row details - modify as you need */
function format ( d ) {
    // `d` is the original data object for the row
    alert(d.lineitems) ;
    return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
        '<tr>'+
            '<td>Order Items:</td>'+
            '<td>'+d.lineitems+'</td>'+
        '</tr>'+
    '</table>';
}
$(document).ready(function() {
    var table_383416 = $('#Table_383416').DataTable( {
        "ajax": "JSONOrderHolds.int?CustNo=383416",
        "columns": [
            {
                "className":      'details-control',
                "orderable":      false,
                "data":           null,
                "defaultContent": ''
            },
            { "data": "ordno" },
            { "data": "buyeraddress" },
            { "data": "shipping" },
            { "data": "ordertotal" },
            { "data": "ccheckbox" }
        ],
        "order": [[1, 'asc']],
        "drawCallback": function( settings ) {
            var tr = $(this).closest('tr');
            alert(tr) ;
            var row = table_383416.row( tr );
            row.child( format(row.data()) ).show();
            tr.addClass('shown');
        }
    } );
    // Add event listener for opening and closing details
    $('#Table_383416 tbody').on('click', 'td.details-control', function () {
        var tr = $(this).closest('tr');
        var row = table_383416.row( tr );
 
        if ( row.child.isShown() ) {
            // This row is already open - close it
            row.child.hide();
            tr.removeClass('shown');
        }
        else {
            // Open this row
            row.child( format(row.data()) ).show();
            tr.addClass('shown');
        }
    } );
} );
</script>
This discussion has been closed.