Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expandable rows support #68

Closed
nileshmali opened this issue Sep 2, 2014 · 7 comments
Closed

Expandable rows support #68

nileshmali opened this issue Sep 2, 2014 · 7 comments

Comments

@nileshmali
Copy link

@nileshmali nileshmali commented Sep 2, 2014

Is it possible to do expandable row using angular-datatable?
Ref: https://datatables.net/examples/server_side/row_details.html

@l-lin
Copy link
Owner

@l-lin l-lin commented Sep 2, 2014

Using exclusively Angular, it might be possible.
However, the "sure" way is to copy paste the DataTables documentations, ie using jQuery.
So the code would look something like this:

function format(d)  {
    ...
}
$scope.$on('event:dataTableLoaded', function(event, loadedDT) {
    var dt = loadedDT.dt;
    $('#example tbody').on( 'click', 'tr td:first-child', function () {
        var tr = $(this).closest('tr');
        var row = dt.row( tr );
        var idx = $.inArray( tr.attr('id'), detailRows );

        if ( row.child.isShown() ) {
            tr.removeClass( 'details' );
            row.child.hide();

            // Remove from the 'open' array
            detailRows.splice( idx, 1 );
        }
        else {
            tr.addClass( 'details' );
            row.child( format( row.data() ) ).show();

            // Add to the 'open' array
            if ( idx === -1 ) {
                detailRows.push( tr.attr('id') );
            }
        }
    } );

    // On each draw, loop over the `detailRows` array and show any child rows
    dt.on( 'draw', function () {
        $.each( detailRows, function ( i, id ) {
            $('#'+id+' td:first-child').trigger( 'click' );
        } );
    } );
});
@nileshmali
Copy link
Author

@nileshmali nileshmali commented Sep 2, 2014

Thanks.
But I think loadedDT.dt in event:dataTableLoaded will be available in next release right?

@l-lin
Copy link
Owner

@l-lin l-lin commented Sep 2, 2014

Yes. With v0.1.0, you can get the DataTable object with jQuery:

var dt = $('#' + loadedDT.id).DataTable();
@nileshmali
Copy link
Author

@nileshmali nileshmali commented Sep 3, 2014

Thanks for your inputs.
I am closing this issue.

@nileshmali nileshmali closed this Sep 3, 2014
@cmosguy
Copy link

@cmosguy cmosguy commented Jan 31, 2016

I am unable to reproduce this $scope.$on('event:dataTableLoaded', function(event, loadedDT) { within my controller. Is this event even being fired in the 0.5.3 over the angular-datatbles?

@adonis-legon
Copy link

@adonis-legon adonis-legon commented Feb 3, 2017

Hi, is it possible to have the function "format" return an angular expression? I've been trying but it only treat it as a plain html, so I think there must be a way to tell angular to interpret or compile the result of "format" function in order to make it work.. any help?

@aryeharmon
Copy link

@aryeharmon aryeharmon commented Dec 11, 2017

why is this issue closed? still an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.