Get the value of a dataTables cell
Get the value of a dataTables cell
annstimmel
Posts: 2Questions: 0Answers: 0
Hi, all. Apologies if this has been addressed before, but I think I searched through everything without finding a similar question. I've got an array of values that I'm iterating through, looking for matches in my dataTable. To get the values I want from a plain html table, I'd do this:
[code]
$.each(myArray, function(i, v){
$("#myTable tr td:contains("+v+")").each(function(){
alert($(this).text());
})
})
[/code]
The big picture, in cause it might help, is this: myArray is populated based on user interaction with a graph, the values in myArray are used to get row indices from myTable, which are then used to return the values from another column (the above snippet is a test that returns the values from myTable that match those in myArray). I've tried working with fnGetData, but I'm not sure if that's the right approach or, if it is, how I can feed it a node without a table click event.
Any help would be greatly appreciated!!
[code]
$.each(myArray, function(i, v){
$("#myTable tr td:contains("+v+")").each(function(){
alert($(this).text());
})
})
[/code]
The big picture, in cause it might help, is this: myArray is populated based on user interaction with a graph, the values in myArray are used to get row indices from myTable, which are then used to return the values from another column (the above snippet is a test that returns the values from myTable that match those in myArray). I've tried working with fnGetData, but I'm not sure if that's the right approach or, if it is, how I can feed it a node without a table click event.
Any help would be greatly appreciated!!
This discussion has been closed.
Replies
[code]
datatable._('td:contains('+v+')')
[/code]
_ will give you an array of data from what is found based on the jQuery selector - i.e. the selector should pick TR or TD/TH cells from the table and you'll get the data from the cells selected back. If you wanted the cells you could use the $ API method.
Allan