I'm trying to filter a Kendo Grid for sales between a start date and end date but have been unable to do so with filter.push gt and lt. Any help would be appreciated.
var dFrom, dTo;
var dateCriteria = $("#searchCustomerOrder").val();
var dateFrom = new Date(0);
var dateTo = new Date(0);
var pos = dateCriteria.indexOf("-");
if (pos > -1)
{
dFrom = searchCustomerOrder.substring(0, pos);
dTo = searchCustomerOrder.substring(pos + 1);
if (dFrom && dTo)
{
dateFrom = new Date(dFrom);
var secs = dateFrom.getSeconds();
if (secs == 0) {
var milli = dateFrom.getMilliseconds();
milli = milli - 1;
dateFrom.setMilliseconds(milli);
}
dateTo = new Date(dTo);
secs = dateTo.getSeconds();
if (secs == 0) {
milli = dateTo.getMilliseconds();
milli = milli + 86399999;
dateTo.setMilliseconds(milli);
}
if (!isNaN( dateFrom.getTime()) && !isNaN( dateTo.getTime()))
{
$datefrom = dateFrom;
$dateTo = dateTo;
$filter.push(
{ field: "OrderDate", operator: "gt", value: $datefrom });
$filter.push(
{ field: "OrderDate", operator: "lt", value: $dateTo });
}
}
}
var dFrom, dTo;
var dateCriteria = $("#searchCustomerOrder").val();
var dateFrom = new Date(0);
var dateTo = new Date(0);
var pos = dateCriteria.indexOf("-");
if (pos > -1)
{
dFrom = searchCustomerOrder.substring(0, pos);
dTo = searchCustomerOrder.substring(pos + 1);
if (dFrom && dTo)
{
dateFrom = new Date(dFrom);
var secs = dateFrom.getSeconds();
if (secs == 0) {
var milli = dateFrom.getMilliseconds();
milli = milli - 1;
dateFrom.setMilliseconds(milli);
}
dateTo = new Date(dTo);
secs = dateTo.getSeconds();
if (secs == 0) {
milli = dateTo.getMilliseconds();
milli = milli + 86399999;
dateTo.setMilliseconds(milli);
}
if (!isNaN( dateFrom.getTime()) && !isNaN( dateTo.getTime()))
{
$datefrom = dateFrom;
$dateTo = dateTo;
$filter.push(
{ field: "OrderDate", operator: "gt", value: $datefrom });
$filter.push(
{ field: "OrderDate", operator: "lt", value: $dateTo });
}
}
}