We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Problem setting SfDatePicker Min and Max values at runtime

In the attached project, the SfDatePicker Min and Max values can be changed by using the custom "Date Options" button and it works fine as long as this is the first thing the user does. However it only works if the calendar is not yet displayed (by user clicking on it), otherwise the valid dates in the current month won't be available but the ones in the previous/next months will

Note: The Button doesn't show up in the calendar although it is set to.


@code {

public DateOnly? StartDate { get; set; }

DateTime minStartDate = DateTime.Today.Date;

DateTime maxStartDate = DateTime.Today.Date.AddDays(30);


async Task OnDropdownButtonDateOptions(Syncfusion.Blazor.SplitButtons.MenuEventArgs args)

{

if (args.Item == null) { await Task.CompletedTask;}

else if (args.Item.Id == "previousDate")

{

//StartDate = null;

//await InvokeAsync(StateHasChanged);

minStartDate = DateTime.Today.AddDays(-180);

maxStartDate = DateTime.Today;

}

else if (args.Item.Id == "futureDate")

{

//StartDate = null;

//await InvokeAsync(StateHasChanged);

minStartDate = DateTime.Today;

maxStartDate = DateTime.Today.AddDays(180);

}

}

}

Attachment: RPTest_6af1ee72.zip


3 Replies 1 reply marked as answer

UD UdhayaKumar Duraisamy Syncfusion Team January 24, 2023 02:50 PM UTC

We have considered the reported issue "Min and Max date property not working when changing it dynamically" as a bug from our end, and the fix for the issue will be included in any one of our upcoming releases.


You can now track the status of the feedback through the below link,

https://www.syncfusion.com/feedback/40607


Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”


Marked as answer

BJ Ben Junior January 24, 2023 02:56 PM UTC

Ok. Thanks. 

One more thing though: I just realized that there is an error on my first post: 

Note: The Button doesn't show up in the calendar although it is set to.

should be: 

Note: The Clear button doesn't show up in the calendar although it ShowClearButton="true"




UD UdhayaKumar Duraisamy Syncfusion Team January 26, 2023 10:41 AM UTC

The clear icon is typically only displayed when the component has focus and a value entered. This is the intended behavior of the component.


However, if you would like to display the clear icon always, you can use the CssClass property and set it to "e-static-clear". This will override the default behavior and allow the clear icon to be visible at all times.


[CssClass="e-static-clear"]



Loader.
Up arrow icon