我有自定义过滤功能,我需要在下拉列表中更改值时实现它。
function employee_filter(status){
$.fn.dataTable.ext.search.push(
function( oSettings, aData, iDataIndex ) {
// check if current table is part of the allow list
if ( $.inArray( oSettings.nTable.getAttribute('id'), allowFilter ) == -1 )
{
// if not table should be ignored
return true;
}
return aData[8] == status;
}
);
table.draw();
}
HTML:
<form class="form-group">
<select class="form-control" style="width: 25%;" id="employee_filter">
<option value=1>Active Employees</option>
<option value=0>Ex-Employees</option>
<option value="">Show All Employees</option>
</select>
</form>
我向
添加了事件监听器$('select#employee_filter').change( function() {
employee_filter($(this).val());
} );
这不起作用,我只是尽我所能。请帮助我任何建议:)
答案 0 :(得分:0)
$(document).on( "change" , "select#employee_filter" , function(){
employee_filter($(this).val());
});
另外,什么不起作用? 它会返回值吗? 还是不更新表?