disabling available dates

6 posts, 0 answers
  1. KMF
    KMF avatar
    10 posts
    Member since:
    Jul 2008

    Posted 31 Jul 2008 Link to this post

    Can someone tell me how to make only certain dates available. Basically we want to show a calendar, but need to only allow the user to select a date that falls on a Saturday. I am using radCalendarControl for 3.5
  2. Kevin Babcock
    Kevin Babcock avatar
    189 posts
    Member since:
    Mar 2007

    Posted 31 Jul 2008 Link to this post

    Hello K,

    There are methods you can use to configure certain days in the RadCalendar to be unselectable.

    First, you can declare a set of days in the SpecialDays collection. This collection requires that you specify a specific date, and allows you to disable that date from being selected. Fortunately, you can also set the Repeatable property so that every week day that is the same as the week day specified is also disabled (if the date you specified falls on a Monday, all Mondays will be disabled). This requires that you arbitrarily pick 5 dates which fall on the 5 week days and add them to the SpecialDays collection. Here is an example.

    1 <telerik:RadCalendar ID="RadCalendar1" runat="server" >              
    2     <SpecialDays> 
    3         <telerik:RadCalendarDay IsSelectable="false" Repeatable="Week" Date="7/7/2008" /> 
    4         <telerik:RadCalendarDay IsSelectable="false" Repeatable="Week" Date="7/8/2008" /> 
    5         <telerik:RadCalendarDay IsSelectable="false" Repeatable="Week" Date="7/9/2008" /> 
    6         <telerik:RadCalendarDay IsSelectable="false" Repeatable="Week" Date="7/10/2008" /> 
    7         <telerik:RadCalendarDay IsSelectable="false" Repeatable="Week" Date="7/11/2008" /> 
    8     </SpecialDays> 
    9 </telerik:RadCalendar> 

    An alternative method is to use the client-side api to disable the dates. You can intercept the client-side DateClick event, check if the clicked day is a weekday, and disable it as you please. Here is an example of that method:

    1 <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
    3 <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
    4     <script type="text/javascript"
    5         function RadCalendar1_DateClick(sender, args) { 
    6             var day = args.get_renderDay(); 
    7             var isWeekend = day.get_isWeekend(); 
    8             if(!isWeekend) { 
    9                 // unselect the day 
    10                 day.Select(false); 
    12                 // cancel the DateClick event 
    13                 args.set_cancel(true); 
    14             }            
    15         } 
    16     </script> 
    17 </telerik:RadScriptBlock>        
    19 <telerik:RadCalendar ID="RadCalendar1" runat="server" > 
    20     <ClientEvents OnDateClick="RadCalendar1_DateClick" />    
    21 </telerik:RadCalendar> 

    I hope this has been helpful. Please let me know if you have any further questions.

    Kevin Babcock
  3. Jatin
    Jatin avatar
    1 posts
    Member since:
    May 2009

    Posted 29 May 2009 Link to this post

    Hi Kevin,

    I am facing one problem in DateClick event of RAD Calendar control.
    What I am doing is, I am programatically adding special days in a calendar control. I am doing this from server side DayRender method of calendar control.



      Private Sub RadCalNextDateSelection_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs)
     Handles RadCalNextDateSelection.DayRender  
            If e.Day.Date < Now.Date Then  
                e.Day.IsSelectable = False 
                e.Cell.BackColor = Drawing.Color.LightGray  
                e.Day.IsDisabled = True 
            End If  
        End Sub 

    This dates are rendered properly. Also I am not able to select these dates. This is fine. Now when I tried to handle  client side DateClick event of this control and when I click on the special days (for which I have set  IsSelectable = false) 
    I find IsSelectable  = true when I look at "args.get_renderDay()" on client side.
    should I do something extra in order to get the correct value for "IsSelectable" property?


  4. Yavor
    Yavor avatar
    11 posts

    Posted 01 Jun 2009 Link to this post

    Hi Jatin,

    Indeed, the present behavior is observed. I have escalated the issue to our developers, and they will soon correct this discrepancy.
    Thank you for your report.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Jeppe
    Jeppe avatar
    12 posts
    Member since:
    Jan 2009

    Posted 23 Sep 2009 Link to this post


    I am using the RangeMinDate and RangeMaxDate in combination with adding some special days to avoid some dates being picked.(like Sundays) But the special days don not get dimmed out as the days limited by the RangeMinDate. It works that I can´t select them but they are still clickable and the mouse changes on hover.

    Is there a way to avoid this?
  6. Yavor
    Yavor avatar
    11 posts

    Posted 28 Sep 2009 Link to this post

    Hello Jeppe,

    You can apply a special style to the special day, to simulate a disabled effect.
    Additional information on the possible styling of the special days is demonstrated in the following example:


    I hope it gets you started properly!

    All the best,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top