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

Date Filtering in Grid

2 Answers 696 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Craig
Top achievements
Rank 1
Craig asked on 03 Jan 2018, 01:14 AM

For anyone who can help - I'm having an issue with gte and lte on dates in the the grid. It works fine if I put a date before and after one for a start/end date but it does not work if the date happens to be equal. For example I have a date 10/08/2014 I know is in my database for DateEntered but the record will only show if I set start date to 10/07/2014 and enddate to 10/09/2014. Neither of them can be 10/08/2014 - won't work that way even tho those filters imply the "or equal to" part.

Here's my script for the filters:

if ((startDate != "") && (Date.parse(startDate))) {
            datesFilter.filters.push({ field: "DateEntered", operator: "gte", value: new Date(startDate) });
        }

        if ((endDate != "") && (Date.parse(endDate))) {
            datesFilter.filters.push({ field: "DateEntered", operator: "lte", value: new Date(endDate) });
        }

        if (datesFilter.filters.length) {
            $filter.push(datesFilter);
        }

Any help would be greatly appreciated!

Thanks,
Craig

2 Answers, 1 is accepted

Sort by
0
Accepted
Viktor Tachev
Telerik team
answered on 03 Jan 2018, 10:49 AM
Hi Craig,

By default the filter will use the date and time to apply the relevant operation. If you would like the time part to be ignored when filtering I can suggest using one of the approaches described in the following article.


Give the suggestions a try and let me know how they work for you.


Regards,
Viktor Tachev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Craig
Top achievements
Rank 1
answered on 03 Jan 2018, 05:17 PM
Thank you Viktor - that worked perfectly!
Tags
Grid
Asked by
Craig
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Craig
Top achievements
Rank 1
Share this question
or