expand/contract all details rows on all pages
expand/contract all details rows on all pages
I am using the detail row example here: http://datatables.net/release-datatables/examples/api/row_details.html
I have a link on the page that expands/contracts the details row for every table row all at once with:
[code]
$('.datatable tbody td img').live('click', function (event, expand){
var nTr = this.parentNode.parentNode;
if(this.src.match('icon_minus_circle_frame')){
if(expand != 'expand'){
$(nTr).removeClass('no-bottom-border');
/* This row is already open - close it */
this.src = "img/icons/icon_plus_circle_frame.png";
oTable.fnClose( nTr );
}
} else {
if(expand != 'collapse'){
/* Open this row */
this.src = "img/icons/icon_minus_circle_frame.png";
$(nTr).addClass('no-bottom-border');
var nDetailsRow = oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
nDetailsRow.className += ' '+nTr.className;
$(nDetailsRow).slideDown();
}
}
});
$('.datatable. tbody td img').trigger('click', ['expand']);
[/code]
This is almost the same as the example except I'm using the last jquery selector to 'click' all the images. This works great but when I go to the next page in pagination they are still collapsed after clicking the expand all link. I'm not sure how datatables works but I'm assuming it detaches the rows that are out of view for pagination and so the click trigger doesn't catch those rows out of view. Is there a way to expand all details rows even if they are on the next page?
I have a link on the page that expands/contracts the details row for every table row all at once with:
[code]
$('.datatable tbody td img').live('click', function (event, expand){
var nTr = this.parentNode.parentNode;
if(this.src.match('icon_minus_circle_frame')){
if(expand != 'expand'){
$(nTr).removeClass('no-bottom-border');
/* This row is already open - close it */
this.src = "img/icons/icon_plus_circle_frame.png";
oTable.fnClose( nTr );
}
} else {
if(expand != 'collapse'){
/* Open this row */
this.src = "img/icons/icon_minus_circle_frame.png";
$(nTr).addClass('no-bottom-border');
var nDetailsRow = oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
nDetailsRow.className += ' '+nTr.className;
$(nDetailsRow).slideDown();
}
}
});
$('.datatable. tbody td img').trigger('click', ['expand']);
[/code]
This is almost the same as the example except I'm using the last jquery selector to 'click' all the images. This works great but when I go to the next page in pagination they are still collapsed after clicking the expand all link. I'm not sure how datatables works but I'm assuming it detaches the rows that are out of view for pagination and so the click trigger doesn't catch those rows out of view. Is there a way to expand all details rows even if they are on the next page?
This discussion has been closed.
Replies
if you want all rows expanded, you just need one value (true or false) but use the same idea with the draw callback.