Advanced Column Filtering/Conditional Subsetting
Advanced Column Filtering/Conditional Subsetting

Consider the column filtering example here https://datatables.net/extensions/fixedheader/examples/options/columnFiltering.html.
Does anyone have a way to modify the search code below so that it 1) works as constructed now and also 2) allows for conditional subsetting for numeric type variables?
For example, in addition to the current functionality, suppose the user entered <30
(or another operator) in one of the numeric columns to find cases meeting that condition. Is this dual functionality possible?
$(document).ready(function() {
// Setup - add a text input to each footer cell
$('#example thead tr').clone(true).appendTo( '#example thead' );
$('#example thead tr:eq(1) th').each( function (i) {
var title = $(this).text();
$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
$( 'input', this ).on( 'keyup change', function () {
if ( table.column(i).search() !== this.value ) {
table
.column(i)
.search( this.value )
.draw();
}
} );
} );
var table = $('#example').DataTable( {
orderCellsTop: true,
fixedHeader: true
} );
} );
Answers
Instead of using this:
you will need to create a search plugin to compare value ranges. See this example as a demonstration. Maybe you can update this numeric range filter plugin to meet your needs.
Kevin