This is a migrated thread and some comments may be shown as answers.

Kendo Grid: how to push filter between dates

1 Answer 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 20 Nov 2013, 09:30 PM
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 });
                    }
                }
            }

1 Answer, 1 is accepted

Sort by
0
Accepted
Mark
Top achievements
Rank 1
answered on 21 Nov 2013, 03:22 PM
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
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Mark
Top achievements
Rank 1
Share this question
or