How do I create a filter to only show rows containing a checkbox
How do I create a filter to only show rows containing a checkbox
Hi,
I have a table where some of the rows contain a checkbox in a column, but others do not.
There's no other data in the column
I need a filter/search that will just show the rows with a checkbox (it doesn't matter whether it's checked or not)
My JS function looks like this:
$('#EntriesTable').DataTable()
.column(6)
.search('valid')
.draw();
An example table cell looks like this:
<td class="enter">
<input id="Enter_30241_3340138" type="checkbox" value="true"
name="Enter_30241_3340138" data-search="valid"></input>
</td>
When I run this JS, no rows are ever returned
I tried adding the data-search attribute to the <td> tag too, and that made no difference.
I also tried searching for other text in the checkbox HTML, such as 'Enter' or 'true' but this hasn't worked either.
I've also used the data-filter attribute in the same way
I'm using DataTables 1.10.7
What am I doing wrong?
Thanks!
Adam
Answers
Fixed it!
The data-search attribute needs to be on the <td> not the <input> tag, and needs to be on EVERY row: