I'm working with jQuery's DataTables, what I do is include checkboxes to each row, so that you can select several rows at a time, the checxbox ticked from a page shows me their ID for those first 10 rows, but I change to the other page, and when I go back to having it show me the selected checkboxes, it shows me as if it had not been selected.
My question is, how can I make it show me all the selected checkboxes, from several pages of the DataTable?
This is my DataTable:
var otables = $('#doctables').dataTable(
{ "aLengthMenu":[20, 60,80],
"bJQueryUI" : true,
"bProcessing": true,
" bServerSide": true,
"scrollY":"400px",
"sScrollX": '100%',
"sScrollXInner": "100%",
"bScrollCollapse": true,
"ajax": {
"type": "POST",
"url": "../ctrl/datos.php"
},
"bPaginate": true,
"bFilter": true,
"bInfo": true,
"fnCreatedRow": function( nRow, aData, iDataIndex ) {
//creando los cehckbox en la columna 0
$('td:eq(0)', nRow).html( '<input type="checkbox" name="checkbox" id="'+aData[0]+'" class="checkbox" value='+aData[0]+'>');
}
});
and with this button I want to see the value
of the checkbox selected:
$("#button").on("click", function() {
$("input:checkbox:checked").each(function(){
alert($(this).val());
});
});
As my DataTable is paged by 20 rows, I select 3 values from the first page and it shows me well; but when I change to the next 20 rows and select another one, it only shows me the selected value of those last 20 rows and not the previous ones.
How can I solve it?