Using indexOf to lookup the first matching row and return data.
Using indexOf to lookup the first matching row and return data.
I am using the expression
let index = table.column('Person:name').data().indexOf('Chris')
to return the the first 'Chris' that exists my table's 'Person' column. The value of index appears to be an integer pointing to the the matching column array element that matches 'Chris'. Now I would like to use that index to reference the table.row() to get the table.row().data(). I thought that the following might work:
rdata = table.row(index).data()
It did not. Where have I gone wrong? How should I return the data for the row that matches 'Chris' in the table?
Thanks.
This question has an accepted answers - jump to answer
Answers
The index for the column would be the order the data currently is in, so you would need to ensure the rows are in the same order - so change your second code segment to be:
Colin