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

Filter on Date and Time in grid with datepicker

2 Answers 798 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 26 Feb 2019, 02:17 PM

I'm facing an issue where I have properties on my objects that contain a datetime, with a specific time. When I try to filter on these columns in the grid they wont be matched properly since the date used for filtering has the time set to 00:00:00. Is there a prop or option to pass the column somehow, to make sure that time is also being taken into the filtering process?

Thanks!

2 Answers, 1 is accepted

Sort by
0
Andreas
Top achievements
Rank 1
answered on 26 Feb 2019, 09:20 PM

So I managed to get this working with at custom filterCell with at DatePicker component. The issue now is that I need the filter chooser dropdown that you usually get when having filtering enabled for a column.

How do I get that menu in my custom filter cell? The menu where you choose "Equals, After, Before" and so on..

0
Nikolay
Telerik team
answered on 28 Feb 2019, 12:30 PM
Hi,

Here is the filter chooser dropdown:
<DropDownList
    className="k-dropdown-operator"
    iconClassName="k-i-filter k-icon"
    popupSettings={{
        width: ''
    }}
/>

However, I think it will be much easier to use the build-in datetime filter (https://www.telerik.com/kendo-react-ui/components/grid/filtering/). You should handle onFilterChange or onDataStateChange event, loop through the filters collection and replace the filter which value is a datetime object and operator Is equal to "eq" or Is not equal to "neq". You can replace it with two new filters, which will have operators 'greater than' and 'less than', pointing the start and end of day that you filter, or a single filter with a function for an operator. This customization of the FilterDescriptor should be used for the filtering only and the original filter should be passed to the Grid. The FilterDescriptor API can be found here: https://www.telerik.com/kendo-react-ui/components/dataquery/api/FilterDescriptor/.

Regards,
Nikolay
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Janki
Top achievements
Rank 4
Bronze
Iron
Iron
commented on 12 Jul 2021, 04:23 PM

Hi Nikolay,
How can I use the built-in filter="date" within the columnMenu?
Nikolay
Telerik team
commented on 14 Jul 2021, 11:52 AM

Hi Janki,

See this example - https://stackblitz.com/edit/react-b4asyi?file=app%2Fmain.jsx. I just set filter="date" to the date column.

Regards,
Nikolay
Progress Telerik
Daniel
Top achievements
Rank 1
Iron
Iron
commented on 01 Feb 2022, 09:25 AM

Hi Nikolay.

I have the same problem I use ColumnMenu for filter and for the date field I use filterUI props and send the DateTimePicker Component, but how I can choose the operator? how to implement the DropDownList you mentioned above to do that?

Nikolay
Telerik team
commented on 02 Feb 2022, 05:27 PM

Hi Daniel,

As I understood, you need to replace the DatePicker with the DateTimePicker component. Here how it can be done - https://stackblitz.com/edit/react-4xbj95?file=app%2Fmain.jsx.

I hope that helps.

Regards,
Nikolay
Progress Telerik
Daniel
Top achievements
Rank 1
Iron
Iron
commented on 03 Feb 2022, 12:59 PM

Great Thanks, but tell me please how can I inspect the calendar pop up to style it?  every time  I pressed inspect and it disappear from the DOM
Nikolay
Telerik team
commented on 03 Feb 2022, 02:47 PM

Hi Daniel,

Set the DateTimePicker show prop to `true` and once you are ready with the styling, remove it.

Regards,
Nikolay
Progress Telerik
Tags
General Discussions
Asked by
Andreas
Top achievements
Rank 1
Answers by
Andreas
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or