TimePicker Grid Column Filter

2 posts, 0 answers
  1. Joel
    Joel avatar
    207 posts
    Member since:
    Jun 2018

    Posted 16 Apr 2020 Link to this post

    My Grid Column Filter for a Time value is not working by this definition:

     

    Model

    public partial class Session : PropertyBase
    {
        [Display(Name = "Id")]
        public int Id { get; set; }
     
        [Display(Name = "Device Id")]
        public System.Int32? DeviceId { get; set; }
     
        [Display(Name = "Group Id")]
        public System.Int32? GroupId { get; set; }
     
        [MaxLength(50)]
        public System.String UniqueId { get; set; } = $"{Guid.NewGuid()}";
     
        /// <summary>
        /// Track when the session took place
        /// </summary>
        public System.DateTime? Timestamp { get; set; }
     
        [NotMapped]
        [DataType(DataType.Date)]
        public System.DateTime? Date => Timestamp;
     
        [NotMapped]
        [DataType(DataType.Time)]
        public System.DateTime? Time => Timestamp;

     

    Grid

    @(Html.Kendo().Grid<Session>()
        .Name("grid")
        .Columns(columns =>
        {
            columns.Command(command => command
                .Custom("Detail")
                .Click("goDetail"))
                .Width(Glossary.Portal.ButtonWidth);
            columns.Bound(p => p.Date).Title("Date").Format("{0:MM/dd/yyyy}")
                .Filterable(ftb => ftb.Cell(cell => cell.Operator("gte")
                    .ShowOperators(false)));
            columns.Bound(p => p.Time).Title("Time")
                .Format("{0:hh:dd:mm tt}")
                .Filterable(x => x.UI(GridFilterUIRole.TimePicker));
        })
        .Pageable()
        .Sortable()
        .Scrollable()
        .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
        .HtmlAttributes(new { style = "height:550px;" })
        .Selectable()
        .Navigatable()
        .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Read(read => read.Action("IndexJson", "Sessions")
        .Data("gridGetData"))))
  2. Nikolay
    Admin
    Nikolay  avatar
    301 posts

    Posted 21 Apr 2020 Link to this post

    Hello Joel,

    Thank you for sharing the model and the grid implementations.

    I believe that the TimePicker does not filter correctly due to the difference in the format the values are received and the format the filter works with. Could you ensure the Time values are in the following format?

    For your convenience, based on the provided snippets I have prepared a small ASP.NET Core project with Time filter correctly working for a DateTime field.

    Let me know if you have any questions.

    Regards,
    Nikolay
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top