DataTables hidden row details opened via TableTools button
DataTables hidden row details opened via TableTools button
adamclance
Posts: 3Questions: 0Answers: 0
Hi all,
I am trying to open up a hidden row similar to this example: https://datatables.net/examples/api/row_details.html
However, instead of having a plus and minus symbol in its own column I was hoping to open up a hidden row via a datatables button. My problem arises trying to get a handle on the selected row so that I can show the hidden row beneath it.
Is there a way that I can do:
[code]$('#example tbody td img').live('click', function () {
var nTr = this.parentNode.parentNode;
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
}
} );[/code]
except within a tabletools button?
So far I have this within my button:
[code]"fnClick": function() {
var oTT = TableTools.fnGetInstance( 'table' );
var nTr = oTT.fnGetSelected();
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
}[/code]
But I cannot seem to open the hidden row this way.
I'm kind of stumped on this and I'm admittedly new to javascript so any suggestions on how I might go about accomplishing this would be greatly appreciated!
I am trying to open up a hidden row similar to this example: https://datatables.net/examples/api/row_details.html
However, instead of having a plus and minus symbol in its own column I was hoping to open up a hidden row via a datatables button. My problem arises trying to get a handle on the selected row so that I can show the hidden row beneath it.
Is there a way that I can do:
[code]$('#example tbody td img').live('click', function () {
var nTr = this.parentNode.parentNode;
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
}
} );[/code]
except within a tabletools button?
So far I have this within my button:
[code]"fnClick": function() {
var oTT = TableTools.fnGetInstance( 'table' );
var nTr = oTT.fnGetSelected();
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
}[/code]
But I cannot seem to open the hidden row this way.
I'm kind of stumped on this and I'm admittedly new to javascript so any suggestions on how I might go about accomplishing this would be greatly appreciated!
This discussion has been closed.
Replies
The TableTools callback functions are executed in the TableTools instance's own scope - so `this` is the TaleTools instance. You don't need to muck around with fnGetInstance in the callback functions.
So:
[code]
fnClick: function () {
var rows = this.fnGetSelected();
// Loop over rows array and open each
// ...
}
[/code]
Allan
Hi Adam,
I am trying to display details data in the pdf below the main master row.
The data for the details are not visible to user and are displayed by adding a new row when user clicks a row in the data table.
Could you access the hidden data and use it to add to the pdf?