Eric
Eric

Reputation: 768

How do I get cell data from a javascript variable containing a <tr> element

I am using Datatables and the table tools plugin. I can have the selected row returned as a javascript variable. With that variable I want to get the value of a specific cell in each row. I am not sure at all how to do this though. This is basically what I have

var rowData = TableTools.fnGetInstance( 'tableID' ).fnGetSelected();

And what I want to do is something like rowData.children('td'), that doesn't work, but something to that effect.

Upvotes: 1

Views: 2794

Answers (1)

user1339920
user1339920

Reputation:

var cellValue = $("#tableID").dataTable().fnGetData(rowData, colIndex);

Where colIndex is whatever column you want to get the value of (this includes hidden cells).

If you don't care about hidden cells, you could also do:

var cellValue = $(rowData).children("td")...

Upvotes: 2

Related Questions