I have a custom button above my DataTables. When pressed I want it to filter the first column on a attribute value since this column cells only contain images (flags of countries/regions).
My table looks like this:
<table id="example">
<thead>
<tr>
<th>Region</th>
<th>First name</th>
<th>Last name</th>
</tr>
</thead>
<tbody>
<tr>
<td data-order="United States"><img src="img/region_usa.png"></td>
<td>George</td>
<td>Washington</td>
</tr>
<tr>
<td data-order="Europe"><img src="img/region_eur.png"></td>
<td>Michael</td>
<td>Ferguson</td>
</tr>
<tr>
<td data-order="Japan"><img src="img/region_jap.png"></td>
<td>Yuka</td>
<td>Sakamari</td>
</tr>
</tbody>
</table>
This is my initilization:
$('#example').DataTable({
buttons: [
{
text: "Filter: USA",
action: function(e, dt, node, config){
dt.column(0).search("United States").draw();
}
}
]
})
However this doesn't do anything unfortunately. What am I doing wrong?
I used Buttons collection, Buttons.action and column.search() as reference.