Assign Default Datatables Individual Column Filter To Custom HTML Select Drop Down Menu(s)
Assign Default Datatables Individual Column Filter To Custom HTML Select Drop Down Menu(s)
Is it possible to tweak the default Datatables individual column searching/select inputs by overriding the default ones above each column and re-assigning them to specific drop-down menus placed elsewhere? Here's the default functionality:
https://datatables.net/examples/api/multi_filter_select.html
I've read similar posts about re-assigning the default search to a custom HTML input, but wasn't sure if you could do this with the default column drop-down filters. Ideally, I'd like to investigate whether you could create a dynamic,centralized search above the datatable, which includes the re-assigned input field (I've got this piece working in my example) and then re-assign a column (hidden from view) to a drop-downs under the aforementioned search interface like this:
<div>
<input type="text" id="customFilter" />
<br>
<br>
<select id="col2DropDown">
</div>
<table id="datatable">....
Thank you!
wyattburp86
Answers
Got it to work!
Using the example from the aforementioned link, you can target a specific id attribute from the DMO in lieu of the column.footer() portion of this code:
var select = $('<select><option value=""></option></select>')
.appendTo( $(column.footer()).empty() )
Best,
wyattburp86