Reputation: 2654
As far as i know datatable pagination doesn't hide the table rows, when you change the page the table rows are drawn on the table. My problem is that i have some javascript actions that apply to all rows from the table.
I have some inputs on each row which i update with javascript using some conditions and afterwards i submit them.
Is there a way to make the datatable hide the table rows and keep them drawn on the page so i can apply actions to the rows like they are part of the page?
Thanks, Radu
Upvotes: 1
Views: 147
Reputation: 6818
You can use jQuery on the table instance. Something like this:
$('#dataTables-table').dataTable().$('input');
This will return an array of all input fields on your table. (Including on the pages you are not on.)
If you for instance want to check all checkboxes in your form you can do something like this:
$('#dataTables-table').dataTable().$('input[type=checkbox]').each(function () {
$(this).prop('checked', true);
});
Upvotes: 1
Reputation: 368
$('#example').dataTable({
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
switch(aData[0]){
case 'AAAA':
$(nRow).css('color', 'red')
break;
case 'BBBB':
$(nRow).css('color', 'green')
break;
case 'CCCC':
$(nRow).css('color', 'blue')
break;
}
}});
Upvotes: 1