Kendo Grid: how to push filter between dates

2 posts, 1 answers
  1. Mark
    Mark avatar
    4 posts
    Member since:
    Jun 2010

    Posted 20 Nov 2013 Link to this post

    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 });
                        }
                    }
                }
  2. Answer
    Mark
    Mark avatar
    4 posts
    Member since:
    Jun 2010

    Posted 21 Nov 2013 Link to this post

    I resolved this using the information found here: http://www.kendoui.com/forums/kendo-ui-complete-for-asp-net-mvc/grid/can-t-get-grid-datasource-filter-to-work.aspx#boDGAq6aG2OF1P8AAFTdxQ
Back to Top