Server-side child row creation

Server-side child row creation

jacob.steinbergerjacob.steinberger Posts: 86Questions: 18Answers: 1

I've seen this question asked a few times. But these questions and responses combined gave me an idea - if you can include another DataTable as the child row, could you not provide it with it's own ajax call to a server-side script to pull the data? Then the question would be, how could you pass the row id of the parent event through so it's used as a filter to the server-side component.

Or is none of this based in reality? ;)

Answers

  • jacob.steinbergerjacob.steinberger Posts: 86Questions: 18Answers: 1
    edited April 2015

    Ok, so I can take the default child-row example and update the format code to ....

    function format ( d ) {
    return '<table id=journal><tr><thead><th>UID</th><th>Journal</th><th>Date</th></thead></tr></table>';
    }
    

    Then update the onclick ...

            $('#default tbody').on('click', 'td.details-control', function () {
                    var tr = $(this).closest('tr');
                    var row = table.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');
                            journal.ajax.url('/search/journal_ajax.php?sn='+row.servername+'&ss='+row.serverserial).load();
                    }
            } );
    

    I receive no errors, but I never see an attempt to load the ajax URL. I've even pointed it at a bogus URL to see if I can get HTTP log errors. Is there a specific requirement of ajax.url() on when it should be called?

This discussion has been closed.