How can I filter the DateTime bound column after truncating its time from filter

0 Answers 16 Views
Filter Grid
Pol
Top achievements
Rank 1
Iron
Pol asked on 14 Mar 2024, 07:26 AM

I have a model DateTime property called CreatedDate and If I try to filter by date  using the filter 'Is equal to' for a single date, it will not filter the records for the given date due its time part in it filter checking. So How can I make it filter truncating the time part from the filter ?
Pol




public class EmployeeViewModel

{

public string Name{get; set;}

public DateTime  CreatedDate{get; set;}

}

In Kendo Grid
column.Bound(c=>c.CreatedDate).Title("Created Date")

Anton Mironov
Telerik team
commented on 18 Mar 2024, 03:20 PM

Hi Pol,

Thank you for the details provided.

Yes, you are totally correct - the "Is Equal To" filter for the DateTime is taking the time part as well.

In order to achieve the needed filtering behavior, I would recommend adding a helper field in your Model which will use only the Date part of your original field. Show the original column value in your ClientTemplate for the column, but bind the column to the new one.

I hope this information helps.

Kind Regards,
Anton Mironov

 

Pol
Top achievements
Rank 1
Iron
commented on 19 Mar 2024, 09:40 AM

Thanks Anton, it is working for me. Thanks again
Anton Mironov
Telerik team
commented on 19 Mar 2024, 09:50 AM

Hi Pol,

I am glad to hear that the recommended approach is working as expected.

If further assistance or information is needed, do not hesitate to contact the community.


Best Regards,
Anton Mironov

No answers yet. Maybe you can help?

Tags
Filter Grid
Asked by
Pol
Top achievements
Rank 1
Iron
Share this question
or