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

OnDayRender Client Side Data Access Preferred Method

1 Answer 66 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Webmaster
Top achievements
Rank 1
Webmaster asked on 24 Mar 2010, 06:56 PM
I need to be able to disable days based on changing dates in a database.  So my question is what would be the preferred method to do the client side updating to disable the dates?  I do not have access to the dates to be disabled in javascript.  Can I do a server side call in the client side OnDayRender?  Do I need to disable all potential dates when the control is first rendered?  This would not be my preferred method. Do I need to invalidate the control each time the month changes?  If so how would I do that?


1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 30 Mar 2010, 12:57 PM
Hi Kris,

The client-side DayRender event is fired for every calendar day cell when the calendar is rendered as a result of client-side navigation. This event can be used to apply final changes to the output (content and visual styles) just before the content is displayed. Checkout the following demo which shows how to utilize the DayRender client event to customize the appearance of the rendered date.
DayRender Event

Also checkout the forum link: Disable DatePicker Calendar Date on Client Side DayRender
Additionally you could checkout the following code library example which demonstrates how to disable a calendar's days:
http://www.telerik.com/community/code-library/aspnet-ajax/calendar/disabling-calendar-days.aspx

Another approach could be to disable the days on the server. My suggestion would be to disable all the days of the month depending on the condition:
protected void RadCalendar1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
{
   if (e.Day.Date.Month.ToString() == "6")
   {
       DateTime SpecialDate = Convert.ToDateTime("06/11/2009");
       if (e.Day.Date.Date != SpecialDate)
       {
 
           // disable the selection for the specific day
           RadCalendarDay calendarDay = new RadCalendarDay();
           calendarDay.Date = e.Day.Date;
           calendarDay.IsSelectable = false;
           RadCalendar1.SpecialDays.Add(calendarDay);
       }
   }
}

I hope this will help you in getting started.

Regards,
Radoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Calendar
Asked by
Webmaster
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or