Unplanned
Last Updated: 07 Jul 2021 10:49 by ADMIN
Richard
Created on: 07 Jul 2021 10:47
Category: Calendar
Type: Bug Report
1
When you use Calendar and Date Input and they are bound to the same value, you can't change the value correctly upon input

Try to use a Calendar (@bind-RangeStart, @bind-RangeEnd) and Date Input (@bind-value) with the same value bound to them. You can't correctly change the date upon input, it shows only today's date.

 

-------------------- ADMIN EDIT --------------------

The workaround for such a scenario is to not use the @bind-RangeStart, @bind-RangeEnd in Calendar with the same value as Date Input @bind-value. See the code below.

Razor:

<TelerikCalendar Views="1"
                 View="CalendarView.Month"
                 SelectionMode="CalendarSelectionMode.Range"
                 RangeStart="@StartTime"
                 RangeEnd="@EndTime"
                 RangeStartChanged="@((DateTime value) => { StartTime = value.Date + value.TimeOfDay; })"
                 RangeEndChanged="@((DateTime value) => { EndTime = value.Date + value.TimeOfDay; })">
</TelerikCalendar>
<br />
START DATE: @StartTime
<br />
END DATE: @EndTime

<br />

<TelerikDateInput @bind-Value="@inputTimeForStartDate" OnBlur="@OnBlurHandlerFirst" Format="hh:mm">
</TelerikDateInput>

<TelerikDateInput @bind-Value="@inputTimeForEndDate" OnBlur="@OnBlurHandlerSecond" Format="hh:mm">
</TelerikDateInput

C#:

DateTime inputTimeForStartDate { get; set; }
DateTime inputTimeForEndDate { get; set; }

public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }

private void OnBlurHandlerFirst()
{
    StartTime += inputTimeForStartDate.TimeOfDay;
}

private void OnBlurHandlerSecond()
{
    EndTime += inputTimeForEndDate.TimeOfDay;

0 comments