How to use filter() in datatables and get the whole row for it
How to use filter() in datatables and get the whole row for it
How can I get the whole row for the column that I filter that I put in datatables? The user will input the filter and I want the system to search for it without changing the row data of table.
I tried this one
var rowData = $('#table').DataTable().column(2).data().filter(function(value,index){
return value == $('input[name=filter]').val() ? true:false;
}).toArray();
but this will just get the column(2) value if its exist. I want to get all the data in that row. I'm searching only the column(2) but I want to get all the column data or that row where the filter result.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I found this example to work:
http://live.datatables.net/lejahoko/1/edit
If utilizes
rows().indexes()instead ofcolumn().data()and builds an array of row indexes that match the criteria. Then uses those indexes as the row selector to get the data.Kevin
It's not working I tried it and I'm getting a empty result.
This is the code that I tried
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
@kthorngren answered is acceptable I just need to remove the other = in the code. Just like this
Thanks Alot!