column search for date range with datatables

column search for date range with datatables

BlidaAlgBlidaAlg Posts: 9Questions: 4Answers: 0
edited August 2020 in Free community support

hi,
i'm trying to make two input with min date and max date i try this code but nothing work and when the page begin the table starting with no data found... please help

 require(['datatables', 'jquery'], function(datatable, $) {
                 $(document).ready(function() {
              var table = $('#myTable').DataTable();
   
              
              
              $.fn.dataTable.ext.search.push(
   function( settings, data, dataIndex ) {
     var min = $('#date').val();
     var max = $('#date_next').val();
     var date = data[3];
    
      if ( ( isNaN( min ) && isNaN( max ) ) ||
           ( isNaN( min ) && date <= max ) ||
           ( min <= date   && isNaN( max ) ) ||
           ( min <= date   && date <= max ) )
      {
        return true;
      }
      return false;
  }
);
$('#date, #date_next').change( function() {
                  table.draw();
              } );
} );
}

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.