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

TimePicker Grid Column Filter

1 Answer 245 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 2
Iron
Iron
Iron
Joel asked on 16 Apr 2020, 02:35 PM

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"))))

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 21 Apr 2020, 09:21 AM

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.
Tags
Grid
Asked by
Joel
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Nikolay
Telerik team
Share this question
or