how to correctly determine the row index when searching
how to correctly determine the row index when searching

I need to find the index of the row that contains certain information in the 1st column.I tried to solve this problem with such code.
var table=$('#goods').DataTable();
var row=table.search(id_good);
var i=table.row(row).index;
But I didn’t succeed. Where did I make a mistake?
This discussion has been closed.
Replies
Using
var row=table.search(id_good);
isn't going to provide the row results in the variablerow
. Thesearch()
API only affects the rows displayed in the table. Thefilter()
API is used for finding rows that match a particular value and plaving the results in a variable.Kevin
I tried to determine the row index using an expression
but regardless of the value id_good. I get the result 0. What is the code error? How to achieve the desired?
Use the
row-selector
as a function if you want to programmatically find certain rows:Note that I've assumed you are using arrays of data, but if you are using objects your use
data.myProperty === ...
.Allan
thank you very much I was able, thanks to your prompts, to determine the index of the row with the required information, now the code works as it should