jquery - Loop through DataTables table to get all cells content -


i using jquery datatables generate paginated table on site. need run process grabs of data out of particular column. :

$('.testlink').click(function(){             var cells = new array();             $('#mytable tr td').each(function(){                 cells.push($(this).html());             });             console.log(cells);         }); 

that example grabs need information 1 column of tds. guess adding class of tds in row sure there better way. bonus question..

but want know how work datatables? because script hides of table put in pagination function grabs cells visible. played around fngetdata not getting it. ideas?

to access rows, can do:

var rows = $("#mytable").datatable().fngetnodes(); 

in case, should work:

   $('.testlink').click(function(){         var cells = [];         var rows = $("#mytable").datatable().fngetnodes();         for(var i=0;i<rows.length;i++)         {             // html of 3rd column (for example)             cells.push($(rows[i]).find("td:eq(2)").html());          }         console.log(cells);     }); 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -