Just try to give you another option.
All rows in the table are listed below, even if they are filtered:
var currData = []; var oTable = $('#example').dataTable(); oTable.$("tr").each(function(index, row){ //generate your array here // like $(row).children().eq(0) for the first table column currData.push($(row).children().eq(0)); // return the data in the first column currData.push($(row).children().eq(0).text()); });
or if you want the results to match the filter, follow these steps:
var currData = []; var oTable = $('#example').dataTable(); oTable.$("tr", {"filter":"applied"}).each(function(index, row){ //generate your array here // like $(row).children().eq(0) for the first table column currData.push($(row).children().eq(0)); // return the data in the first column currData.push($(row).children().eq(0).text()); });
currData will contain a sorted list of the first column data.
Edit: To get all the string text in an array.
$(row + " td").each(function(index, tdData){ currData.push($(tdData).text()); });
or
$(row).children().each(function(index, tdData){ currData.push($(tdData).text()); });
This way you have a bit more control over what the array can contain. My 2 cents.
Bret
source share