.rows() method returns unexpected result
.rows() method returns unexpected result
walrus
Posts: 5Questions: 2Answers: 0
I have my DataTable, like that:
var myData = [
{item: 'apple', color: 'red'},
{item: 'pear', color: 'green'},
{item: 'pinaple', color: 'yellow'},
{item: 'banana', color: 'yellow'}
];
var dataTable = $('#mytable').DataTable({
sDom: 't',
data: myData,
columns: [
{data: 'item', title: 'item'},
{data: 'color', title: 'color'}
]
});
var selectedRow = dataTable.rows(1,{order:'applied'}).data();
$('#requested').text(JSON.stringify(selectedRow[0]));
And the question is why .rows(1, {order:'applied'})
refers to the second row of source data set and not actual current table layout?
Here is a playground.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
This thread will be of interest to you:
https://datatables.net/forums/discussion/comment/139825/#Comment_139825
Updated your example with the jQuery workaround that Colin provided.
https://jsfiddle.net/joL1fmeh/
Kevin