How to get access of a cell's value?
How to get access of a cell's value?
ngungo
Posts: 64Questions: 23Answers: 2
How do I get value of a cell cellval so I can use it later in the fnRowCallback? Any hint will be appreciated.
$(document).ready(function() {
var cellval = ...
var table = $('#cases').DataTable( {
ajax: 'php/table.cases.php',
"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
console.log(cellval);
},
});
});
This question has accepted answers - jump to:
This discussion has been closed.
Answers
The data that is used to make up the row is in
aData
in your above code. So you might useaData[0]
if you are using an array data source, oraData.myProp
if you are using objects.Allan
Thanks Allan!
How about outside and before the definition of var table?
Use
cell().data()
to get the data for a cell.Allan
Hi Allan,
Your two previous answers help me to understand more about the nuts and bolds of the DataTables, but neither
aData
norcell().data()
would help since their existences were created by definition oftable
. In my case, I need to have access of the cells without and before the definition of table. Is there way?Sure - just use jQuery -
$('#myTable tbody tr td')
. You'd probably need to add extra information to the selector, such as the row and column index, but that's not a DataTables issue.Allan