Vivien Pipo Vivien Pipo - 1 year ago 59
Javascript Question

How to loop through all rows in DataTables jQuery?

I am using jquery plugin DataTables for building nice table

var table = $('#example').DataTable({
"data": source

I would like that make an each for all rows in table

Unfortunately this way may be out of date and does't work with new version (it launchs an error)

$(table.fnGetNodes()).each(function () {


And this way only works only for visibles rows (10 first rows because other rows are paginated)

table.each( function ( value, index ) {
console.log( 'Data in index: '+index+' is: '+value );
} );

Do you known how to loop to all rows please?

Answer Source

i finally found:

 var data = table.rows().data();
 data.each(function (value, index) {
     console.log('Data in index: ' + index + ' is: ' + value);