How to Filter rows that have a checkbox ticked?
How to Filter rows that have a checkbox ticked?
What I would like to do is filter all rows that have a checkbox ticked in the data table.
I have a custom button created but I seem to be having a problem being able to select the element to see if it is ticked or not.
Structure for a row looks like this:
<tr>
<td>Some Data</td>
<td>Some Data</td>
<td>Some Data</td>
<td>Some Data</td>
<td>Some Data</td>
<td>Some Data</td>
<td><span class="disabled"><input id="someId" name="somename" checked="checked"></span></td>
</tr>
This is the code I have running inside the function for my custom button:
$.fn.dataTable.ext.search.push(
function (settings, data, dataIndex) {
console.log($(table.row().node()));
return $(table.row(dataIndex).node('#MainContent_EnquiriesMainContent_StaffGridView_ctl01_0[type=checkbox]'));
}
);
table.draw();
This obviously isn't working but I just can't work out how to inspect the element.
I realise that it should be something like: $(table.row(dataIndex).node().attr( ) ) but I just can't work it out.
The console log shows all the rows being returned so I am half way there!!
Thanks in advance
Answers
Maybe this will work in your function:
I think you will want to use
.prop()
instead of.attr()
.Kevin