Keep selected rows when I go to another page
Keep selected rows when I go to another page
jgcaudet
Posts: 82Questions: 7Answers: 0
Hi Allan
I want to select mutiple rows that are in different pages of my datatable. I use multiselect TableTools. I select some rows in the page I see in this moment (page A), then I go to another page (page B) and when I return to page A all the rows I selected in this page are deselected.
I need to select multiple rows in different pages in order to generate a unique csv file.
Is possible to do this ? How ?
Thanks
I want to select mutiple rows that are in different pages of my datatable. I use multiselect TableTools. I select some rows in the page I see in this moment (page A), then I go to another page (page B) and when I return to page A all the rows I selected in this page are deselected.
I need to select multiple rows in different pages in order to generate a unique csv file.
Is possible to do this ? How ?
Thanks
This discussion has been closed.
Replies
What I'll do is look at introducing a new mode into TableTools which can use the row ID of rows to retain select - a bit like this method: http://datatables.net/release-datatables/examples/server_side/select_rows.html . That should be in TableTools 3, although that won't be until after DataTables 1.10 is released.
Allan
I´ll wait Table Tools 3 and DataTables 1.10. (without drinking, eating, ... jaja)
Thanks Allan
Allan
oTable = $('#example').dataTable( {
..... ,
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
if ( jQuery.inArray(aData.DT_RowId, aSelected) !== -1 ) {
// Si la fila esta en el array de filas seleccionadas, la muestro como seleccionada
oTT.fnSelect( $('#example tbody tr')[iDisplayIndex] ) ;
}
}
} );
..................
/* Click event handler */
$(document).on( 'click', '#example tbody tr', function () {
var id = this.id;
var index = jQuery.inArray(id, aSelected);
var rowIndex = $('#example tbody tr').index(this);
if ( index === -1 ) {
aSelected.push( id );
oTT.fnSelect( $('#example tbody tr')[rowIndex] ) ;
} else {
aSelected.splice( index, 1 );
oTT.fnDeselect( $('#example tbody tr')[rowIndex] ) ;
}
} );
but when I export to excel, csv or pdf with "bSelectedOnly": true, only export selected rows in the page I see in this moment. How can I fix this ? Is possible ?
Also I would need that "Select All" and "Deselect All" TableTools buttons, fill or empty aSelected array. Is this possible ? How ?