jquery datatable display details

Asked

Viewed 244 times

0

I have a jQuery Datatable that has detail, where click on the line expands the detail tamplate that makes a request to the server and brings different data from the main table, I followed this Example

But my prolema now is the following, I need that instead of the tamplate being a detail that expands as the line click, I need that it is always visible, a detail that is not hidden. My question is how to make the main datatable automatically load the detail since it does a part request.

At the end I will need to print out my main datatable, printing it and the detail.

Example:

Coluna1| Coluna2| Coluna3|
Valor1   Valor2   Valor3
  Detalhe1| Detalhe2| Detalhe3|
  ValorD1   ValorD2   ValorD3 
  • you want it to load and already remain open, but do not want to lose this functionality, IE, the expand/hide button should continue working? Or you just want the details to appear and delete the expand/hide button?

  • I just want the details to appear by deleting the expand/hide button as I need to make a print of this datatable afterwards.

1 answer

0

Comment on everything inside:

$('#example tbody').on( 'click', 'tr td.details-control', function () {
//comentar
});

And add the code:

var trs = $('#example tbody tr');

for(var i = 0, len = trs.length; i < len; ++i) {
    var tr = trs[i];
    var row = dt.row( tr );
    row.child( format( row.data() ) ).show();
}

To hide the comment css buttons:

td.details-control {
    background: url('../resources/details_open.png') no-repeat center center;
    cursor: pointer;
}
tr.details td.details-control {
    background: url('../resources/details_close.png') no-repeat center center;
}
  • Djalma, I did as you told me, but from what I understood, the example is still on the column click, what I need is that it did not occur on any click, that it was automatic, know how to tell me how to make it happen?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.