How to filter on a date column with daterangepicker
How to filter on a date column with daterangepicker
Hi,
I attempt to make this function to work with just one data search field, my search field contain the start and the end values (with daterangepicker).
So I need to past the two values to the same search for the column.
This is working if I past just one value --> datatables.columns(7).search(startdate);
But what I need is sommething like : datatables.columns(7).search(startdate,enddate);
I have checked to$.fn.dataTable.ext.search.push but I don't understant how to make it workig.
Can you help me?
Best regards.
//Filter the datatable on the datepicker apply event
$('#idReportrange').on('apply.daterangepicker', function(ev, picker)
{
startdate=picker.startDate.format('YYYY-MM-DD');
enddate=picker.endDate.format('YYYY-MM-DD');
$('#idReportrange').val(startdate + ' - ' + enddate);
alert(startdate+" "+enddate);
datatables.columns(7).search(startdate);
datatables.draw();
});
Replies
See if this example gets you started:
https://datatables.net/examples/plug-ins/range_filtering.html
Kevin
Hi Kevin,
I have checked it, it's about it I said "I have checked to $.fn.dataTable.ext.search.push but I don't understand how to make it working."
My problem is that I don't know how to past the two values (start and end) to the datatable search.
Diedeer
... I d'on't have two fields #min and #max, I have just one field #minmax
Diedeer
I believe you are getting the start and end values with this code:
I would look at using those as global variables that can be used within the search API. If this doesn't help please start a test case so we can help you finish your code.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin