Get specific cell value using row/col index coordinates
Get specific cell value using row/col index coordinates

Hi,
I want to read the value of a specific hidden cell, when I have the row integer index and the column integer index.
I tried many things, which I wrote below :
// This is the syntax I thought it would work. But in fact it gets first column of all rows in an array. Odd, to say the least.
console.log( table.rows(rowIndex).columns(colProduct).data() );
// This gets the first row, with no surprise.
console.log( table.rows(rowIndex).data() );
// This gets the correct cell value that I'm looking for. However if there is a better way of doing, I would prefer using something that is better understandable.
console.log( table.rows(rowIndex).data()[0][colProduct] );
Thanks
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @mikeosoft ,
The
cells()
is the way to go through the DataTables API. One consideration though, is that the rowIndex, is the order in which the row was loaded, not the order it is currently displayed. If you want it based on the current position in the table, it's probably easiest to use jQuery as in this live example here.Cheers,
Colin
Edit: never mind. I just clicked on the link you gave and realized it's not taking me to the same api pages I had previously landed on when clicking a same named link on another part of this site. I would delete my comment but don't see how.
@colin An example would be appreciated. I've been trying to figure this out using the cells api, but I only see examples on how to get the value of "this". Of course "this" doesn't help me when the cell I want isn't in context, and everything I've tried so far doesn't seem to work.
Hi @brandonvmoore ,
There's an example in my post above, that shows how
cells()
can be used. It would be worth creating a new thread if you have a specific problem with that method.Cheers,
Colin
...