views:

400

answers:

2

Anyone know how to add a custom option select filter to a jQuery DataTable?

Basically, like this example page but instead of having min/max text fields... change them to select options.

A: 

Easier than I thought it would be:

Javascript

$(document).ready(function() {
    /* Initialise datatables */
    var oTable = $('#example').dataTable();

    /* Add event listeners to the two range filtering inputs */
    $('select#engines').change( function() { oTable.fnFilter( $(this).val() ); } );
} );

HTML

<select id="engines">
    <option value="">- Select -</option>
    <option value="1.8">1.8</option>
    <option value="1.9">1.9</option>
</select>
Jeffrey
A: 

But this does not solve the problem, it does not search a range. It just filters base on the exact value.

Jie
True, it doesn't search a range... though I can't devote anymore time to this concern. If you know how to achieve this, I'd be grateful to know.
Jeffrey