How can i find row and column indexes of certain value With datatable?
How can i find row and column indexes of certain value With datatable?
toroNGT
Posts: 7Questions: 2Answers: 0
I have certain string value. I want to search that value in DataTable and get the row and column indexes of that value. How Can i accomplish this with datatable?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Hi @toroNGT ,
You can use
search()
to search the table which would then put those matching rows into the table.table.rows( {search:'applied'} ).indexes()
would return the row index of those matching records.Hope that helps,
Colin
Dear @colin
The problem is that i am using
table.columns(index).search(val).draw();
code to filter DataTable. I do not want the previous search results, that are displayed to the user to be changed and i do not want to change searchval
value. I just want to search whole datatable (under whole i mean whole table data, ignoring currently applied by searchval
value) and get row and column indexes.How can i accomplish that?
Hi @toroNGT ,
You can just get the data in an array with something like,
table.rows().data()
, and iterate through the array to see if it matches. Also,filter()
may work for you too.Cheers,
Colin
Dear @colin
Thank you for your response. I have not tried
filter()
method. Because i was able to solve my problem using row-selector function with following code:Are there any downsides of this approach?
Hi @toroNGT ,
That's as good a way to go as any other
Cheers,
Colin