How to filter rows on selected dropdownlist value?
How to filter rows on selected dropdownlist value?
Hey there,
i would like to know if there is any function to filter a datatable that includes columns with dropdownlist elements?
if we have a dropdownlist with values
<select class="form-control selectBoxForCustomData">
<option>Not done</option>
<option>Done</option>
<option>Yes - failed</option>
<option selected="selected">N/A</option>
<option>Checked by DL</option>
<option>-</option>
</select>
and we search all rows that have "Done" selected
-> <option selected="selected">Done</option>
i tried something like
table.column(index).data().search('Done').draw()
but that draws all rows because the option value "Done" is in every row.
How can i do a HTML search on every row?
eg.: search('<option selected="selected">Done</option>').draw()
Another solution could be adding a hidden html data field with the selected value, but i still need to search in the raw HTML data...
<input value="Done" id="item_ProjectCustomData_XY" name="item.ProjectCustomData.XY" type="hidden">
Haven´t found a solution, yet.
Answers
Workaround:
set the data-search attribute on the <td> - element and add a changehandler for all dropdownlists.
fiddle