user3165474 user3165474 - 2 months ago 15
jQuery Question

Datatables plugin - Select Date Range

i found a guide to select age range such as :

Html file :

<table border="0" cellspacing="5" cellpadding="5">
<tbody>
<tr>
<td>Minimum age:</td>
<td><input type="text" id="min" name="min"></td>
</tr>
<tr>
<td>Maximum age:</td>
<td><input type="text" id="max" name="max"></td>
</tr>
</tbody>
</table>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Date</th>
<th>Salary</th>
</tr>
</thead>
</tbody>
</table>


Javascript file :

/* Custom filtering function which will search data in column four between two values */
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
var min = parseInt( $('#min').val(), 10 );
var max = parseInt( $('#max').val(), 10 );
var age = parseFloat( data[3] ) || 0; // use data for the age column

if ( ( isNaN( min ) && isNaN( max ) ) ||
( isNaN( min ) && age <= max ) ||
( min <= age && isNaN( max ) ) ||
( min <= age && age <= max ) )
{
return true;
}
return false;
}
);

$(document).ready(function() {
var table = $('#example').DataTable();

// Event listener to the two range filtering inputs to redraw on input
$('#min, #max').keyup( function() {
table.draw();
} );
} );


what i'm trying to achieve is to find a min and max Date Range by using bootstrap calendar popup.

It is possible to change row search
(data[4] ) || 0; // use data for date column


The question is how can i search the date?
Formated :
9/27/2016


I'm completely new in java script.

Answer

http://jsfiddle.net/dipakthoke07/evcfespn/96/

I have apply the search to date column.you need to select date range it retrive data from that range:

Comments