Declined
Last Updated: 23 Apr 2021 07:19 by ADMIN
Marc Simkin
Created on: 22 Apr 2021 14:47
Category: DatePicker
Type: Feature Request
1
DisabledDates should accept a collection of start/end dates

Currently, when dates need to be disable in the DatePicker and DateRangePicker, a collection of induvial dates are provided.  As a result, when I need to disable a 90 day or 180 day continuous range I need to add to the collection 90 or 180 day individual DateTime objects.

It would be more efficient to provide a range of dates to disable instead of induvial dates.

The DisabledDates should accept a collection of DisableDateItems that is similar to the below:

public class DisableDateItem
{
     public DateTime RangeBegin { get; set; }
     public DateTime RangeEnd { get; set; }
}

Using this collection I can disable an individual date by having the RangeBegin and RangeEnd dates be the same, as shown below:

var bankHoliday = new DisableDateTime
{
       RangeBegin = new DateTime(2021, 09, 01),
       RangeEnd = new DateTime(2021, 09, 01)
};


To disable a date range, for example the Eastern Good Friday Weekend, I would provide a DisableDateTime as:

var bankHoliday = new DisableDateTime
{
       RangeBegin = new DateTime(2021, 04, 30),
       RangeEnd = new DateTime(2021, 05, 02)
};

To disable a 90 day range, I would provide a DisableDateTime object as:

var bankHoliday = new DisableDateTime
{
       RangeBegin = new DateTime(2021, 05, 01),
       RangeEnd = new DateTime(2021, 07, 30)
};
1 comment
ADMIN
Marin Bratanov
Posted on: 23 Apr 2021 07:19

Hi Marc,

Adding some special class that people need to know about would add a layer of confusion and I do not believe it will make the component significantly easier to use.

The disabled dates collection is designed for relatively small numbers of items that are in some way special and you would generally get them from a service already prepared as a collection.

For entire ranges, you can easily generate the list of dates with a single line of C# based on a start and end date you have: https://stackoverflow.com/questions/3738748/create-an-array-or-list-of-all-dates-between-two-dates. You can easily refactor this into a reusable method in your app if you need to do that often.

If you have very large lists of continuous dates that are not allowed, perhaps a proper Min and Max setting might be more suitable for the scenario.

With that in mind, I must mark this as "Declined" because it is very easy to shape data for the current API that is exposed without more layers of abstraction.

Regards,
Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.