Closed Vokchaks closed 3 years ago
Hi Vladimir,
Share your implementation of DaysEnabledFunction
please, or better share the whole @code
block because there is no problem with the code you posted.
And you don't need @bind-
for MinDate or MaxDate because they will never be changed inside the DateRangePicker.
Disable days only: 12 and 13
It seems there is an issue with your AData.GetDatesAsync(date)
implementation, could you share it please? Also there are some non-critical issues in your code, for example:
EnabledDays.Add(day)
in FillDisabledDates
invoked twice?SingleDatePicker="true"
.It seems there is an issue with your AData.GetDatesAsync(date) implementation, could you share it please? Also there are some >non-critical issues in your code, for example:
Why EnabledDays.Add(day) in FillDisabledDates invoked twice?
I tried both ways wirh onсe and with twice — the result is unchanged
<Why you use range selection mode if you need only single date selection? You can just use SingleDatePicker="true".
I tried this. fixed again
Attach picture afer change code
async Task FillDisabledDates(DateTime date)
{
if (EnabledDays.Exists(d => d.DateTime.Month == date.Month))
return;
//Debug.WriteLine($"FILL MONTH: {month} ");
//List<DateTime> dates = await AData.GetDatesAsync(date);
List<DateTime> dates = octouber2019;
foreach (var day in dates.OrderBy(d => d))
{
Debug.WriteLine($"DAY: {day} ");
EnabledDays.Add(day);
// EnabledDays.Add(day);
}
Debug.WriteLine($"ENABLE DAYS COUNT: {EnabledDays?.Count} ");
}
List<DateTime> octouber2019 = new List<DateTime> {
new DateTime(2019,10,01),
new DateTime(2019,10,02),
new DateTime(2019,10,03),
new DateTime(2019,10,04),
new DateTime(2019,10,05),
new DateTime(2019,10,06),
new DateTime(2019,10,07),
new DateTime(2019,10,08),
new DateTime(2019,10,09),
new DateTime(2019,10,10),
new DateTime(2019,10,14),
new DateTime(2019,10,15),
new DateTime(2019,10,16),
new DateTime(2019,10,17),
new DateTime(2019,10,18),
new DateTime(2019,10,19),
new DateTime(2019,10,20),
new DateTime(2019,10,21),
new DateTime(2019,10,22),
new DateTime(2019,10,23),
new DateTime(2019,10,24),
new DateTime(2019,10,25),
new DateTime(2019,10,26),
new DateTime(2019,10,27),
new DateTime(2019,10,28),
new DateTime(2019,10,29),
new DateTime(2019,10,30),
new DateTime(2019,10,31), // !!!
};
}
The problem is probably with the MaxDate
property. Try setting MaxDate
to 31.03.2019 23:59:59
please.
Thanks. It fixed 31.10, but how I must to disable 30.09 ?
The MaxDate
property has nothing to do with DaysEnabledFunction
so there should be no problem.
The
MaxDate
property has nothing to do withDaysEnabledFunction
so there should be no problem.
But, it problem - the screenshot above . In list oktober2019 not present september
But you're only comparing the day component inside your DaysEnabledFunction
:
public bool DaysEnabledFunction(DateTimeOffset day)
{
return EnabledDays.Any(d => d.Day == day.Day);
}
then change it with something like
public bool DaysEnabledFunction(DateTimeOffset day)
{
return EnabledDays.Any(d => d.Date == day.DateTime.Date);
}
Yes! Thanks, very match
I used only one calendar
but when I add the enable dates - the last date of the month is set disabled help me, please