有人知道如何在jQuery DataTable中添加自定义选项选择过滤器吗?
基本上,像这个示例页面,但是不是使用最小/最大文本字段...而是将它们更改为选择选项。
比我想象的更容易:
Javascript
$(document).ready(function() {
/* Initialise datatables */
var oTable = $('#example').dataTable();
/* Add event listener to the dropdown input */
$('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>
oTable.fnFilter("([1-9][3-9]|[2-9][0-9]|[0-9]{3,})", 1, true);