This is a migrated thread and some comments may be shown as answers.

Adding Special Days on demand.

1 Answer 69 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Ivan
Top achievements
Rank 1
Ivan asked on 01 Feb 2011, 02:03 AM
Hi.

I'm using a DatePicker to show data about a specific date, and there are also dates in which no data is related. Hence, I'm populating the picker with special days using the OnLoad event, enabling and disabling the dates between the MinDate and MaxDate, as it's being needed.

This is how I've done so far, populating from the picker's MinDate to the MaxDate, which works, but I'd like to populate by requesting dates everytime I navigate, within the picker's CalendarView, so everytime a request occurs, I only process no more than 40 Special Days, not every date of several months and so on:

protected void DatePicker_Load(object sender, EventArgs e)
{
            RadDatePicker picker = sender as RadDatePicker;
 
            DateTime[] dates = controller.GetCustomerBaseDates();
 
            picker.MinDate = dates.Min();
            picker.MaxDate = dates.Max();
 
            for (DateTime d1 = picker.MinDate; d1 <= picker.MaxDate; d1 = d1.AddDays(1))
            {
                RadCalendarDay day;
 
                bool exists = dates.Contains(d1);
 
                day = new RadCalendarDay { Date = d1, IsSelectable = exists, IsDisabled = !exists };
                day.ItemStyle.CssClass = exists ? "rcDataExists" : "rcDisabled";
 
                picker.Calendar.SpecialDays.Add(day);
            }
}


How could I add the special days every time navigation occurs?  I want to enable and disable these dates on navigation within the view, because a lot of dates would be involved in the process.

Regards.

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 03 Feb 2011, 03:07 PM
Hello Ivan,

In order to achieve your goal, you will need enable the picker's calendar AutoPostBack. However this is not supported out-of-the-box. And to implement it, you can follow the approach illustrated here.

Check it out and let me know if it works for you.

All the best,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Calendar
Asked by
Ivan
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or