Hello everyone,
I'm trying to filter my table based on the class names.
here is my html
<table>
<tr class="alert">
<td>Jim</td>
<td>04/12/2020</td>
</tr>
<tr>
<td>Jason</td>
<td>12/08/2021</td>
</tr>
<tr class="alert">
<td>Alex</td>
<td>05/27/2021</td>
</tr>
</table>
I would like to be able to search for "alert" in my search bar, and get the first and third row as result (of course, I also want to be able to do a classic search, by "Alex" or "12/08/2021").
Here is my current code, but it filters the table automatically on page loads. I'd like to do this only when I type something into the input.
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
return $(table.row(dataIndex).node()).hasClass('alert');
}
$('#custom-filter').keyup(function () { // I'm using a custom input
table.search(this.value).draw();
});
And if you can magically tell me how to be able to sort column 3 (European date format), you will make me a very very happy man.
Thanks to all of you