Hi,
I have had an issue with the DatePicker.
My fault finding led me to using the very basic example in the "documentation/datepicker/data-binding/" with the addition of a dropdown that changes the value of the variable being used as the value of the DatePicker.
The DropDown is populated with 3 dates. It is possible to use the DropDown repeatedly to change the value of the DatePicker and the value shown in the <p> on the page.
So using the Dropdown works as expected until you use the DatePicker to select a date. Once this has been done, using the Dropdown to change the variable value has no effect on the DatePicker, but the value shown in the <p> on the page continues to show that the variable value is changing.
After the DatePicker becomes non responsive to the changes made by the DropDown, if you click on the DatePicker to expose the Calendar, it displays the currently selected date as the one in the variable rather than the one shown by the DatePicker as its current value.
I have carried out the same experiment with the Date|TimePicker and had the same results. However, with the DateTimePicker once it is not changing to show the value of the variable, if you then make a change to the time, the date will then update to show the value of the variable.
The code is below...
@page "/TestDatePickerChange"
@using Syncfusion.Blazor.Calendars;
@using Syncfusion.Blazor.DropDowns;
@using System.Collections.Generic;
<h3>TestDatePickerChange</h3>
<p>DatePicker value is: @DateValue</p>
<SfDatePicker TValue="DateTime?" Value="@DateValue">
<DatePickerEvents TValue="DateTime?" ValueChange="@onChange"></DatePickerEvents>
</SfDatePicker>
<br />
<br />
<SfDropDownList id="DirectionDropdownPlaceholder" Placeholder="Both" DataSource="@DropdownList" TValue="string" TItem="string">
<DropDownListEvents ValueChange="@DropDownChanged" TValue="string" TItem="string"></DropDownListEvents>
</SfDropDownList>
@code {
public DateTime? DateValue { get; set; } = DateTime.Now;
private void onChange(Syncfusion.Blazor.Calendars.ChangedEventArgs<DateTime?> args)
{
DateValue = args.Value;
StateHasChanged();
}
List<string> DropdownList = new List<string>{ "24/02/1922", "12/07/2000", "16/09/1996"};
public void DropDownChanged(@Syncfusion.Blazor.DropDowns.ChangeEventArgs<string, string> args)
{
DateValue = DateTime.Parse(args.Value);
}
}
Is this a bug? or is there another way to cause the DatePicker to update?
Thanks and Happy Holidays - Martin