Dropdown instead of search box.
Dropdown instead of search box.
I am using the Zero Configuration example under Basic initialization. I would like to replace the search text box with a hardcoded dropdown ie:
<select>
<option>Red</option>
<option>White</option>
<option>Blue</option>
</select>
Is this possible?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Answered my own question. Make sure the select has an ID :
<select id="colors"> <option>Red</option> <option>White</option> <option>Blue</option> </select>
javascript portion:
$(document).ready(function() {
var oTable = $('#example').DataTable( {
"scrollY": "500px",
"scrollCollapse": true,
"paging": false
} );
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
var selectedColor = $('#colors').val();
var color = data[0]; // use data for the color column
);