Range date filter was working before using server side
Range date filter was working before using server side
Hi,
I am using this function to filter by date range
[code] $.fn.dataTableExt.afnFiltering.push(
function( oSettings, aData, iDataIndex ) {
if(typeof col[table].date == "number"){
var iMin = $('#min').val();
var iMax = $('#max').val();
var pDate = col[table].date;
var iVersion = aData[pDate] == "-" ? 0 : aData[pDate];
iVersion = iVersion.substr(0,10);
console.log(iVersion)
if ( iMin == "" && iMax == "" )
{
return true;
}
else if ( iMin == "" && iVersion <= iMax )
{
return true;
}
else if ( iMin <= iVersion && "" == iMax )
{
return true;
}
else if ( iMin <= iVersion && iVersion <= iMax )
{
return true;
}
return false;
}
else
return true;
}
);
$("#min").change(function(){
oTable.fnDraw();
})
$("#max").change(function(){
oTable.fnDraw();
})[/code]
Why this doesn't works? Before I was using getJSON to fetch my data and it was working, now I'm using server-side and doesn't works anymore, even though it return true.
Any clue are welcome.
I am using this function to filter by date range
[code] $.fn.dataTableExt.afnFiltering.push(
function( oSettings, aData, iDataIndex ) {
if(typeof col[table].date == "number"){
var iMin = $('#min').val();
var iMax = $('#max').val();
var pDate = col[table].date;
var iVersion = aData[pDate] == "-" ? 0 : aData[pDate];
iVersion = iVersion.substr(0,10);
console.log(iVersion)
if ( iMin == "" && iMax == "" )
{
return true;
}
else if ( iMin == "" && iVersion <= iMax )
{
return true;
}
else if ( iMin <= iVersion && "" == iMax )
{
return true;
}
else if ( iMin <= iVersion && iVersion <= iMax )
{
return true;
}
return false;
}
else
return true;
}
);
$("#min").change(function(){
oTable.fnDraw();
})
$("#max").change(function(){
oTable.fnDraw();
})[/code]
Why this doesn't works? Before I was using getJSON to fetch my data and it was working, now I'm using server-side and doesn't works anymore, even though it return true.
Any clue are welcome.
This discussion has been closed.
Replies
Allan
[code]if((isset($_GET['min']) || isset($_GET['max'])) && ($_GET['min'] != '' || $_GET['max'] != '')){
$min = mysql_real_escape_string($_GET["min"]);
$max = mysql_real_escape_string($_GET["max"]);
if ( $sWhere == "" )
{
$sWhere = "WHERE ";
}
else
{
$sWhere .= " AND ";
}
if(!isset($_GET["max"]) || $_GET['max'] == ''){
$sWhere .= " created_at >= '$min' ";
}
if(!isset($_GET["min"]) || $_GET['min'] == ''){
$sWhere .= " created_at <= '$max' ";
}
if(isset($_GET['min']) && isset($_GET['max']) && $_GET['min'] != '' && $_GET['max'] != ''){
$sWhere .= " created_at BETWEEN '$min' AND '$max' ";
}
}[/code]