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

disabling available dates

5 Answers 298 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
KMF
Top achievements
Rank 1
KMF asked on 31 Jul 2008, 09:31 PM
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

5 Answers, 1 is accepted

Sort by
0
Kevin Babcock
Top achievements
Rank 1
answered on 01 Aug 2008, 01:46 AM
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.

<telerik:RadCalendar ID="RadCalendar1" runat="server" >              
    <SpecialDays> 
        <telerik:RadCalendarDay IsSelectable="false" Repeatable="Week" Date="7/7/2008" /> 
        <telerik:RadCalendarDay IsSelectable="false" Repeatable="Week" Date="7/8/2008" /> 
        <telerik:RadCalendarDay IsSelectable="false" Repeatable="Week" Date="7/9/2008" /> 
        <telerik:RadCalendarDay IsSelectable="false" Repeatable="Week" Date="7/10/2008" /> 
        <telerik:RadCalendarDay IsSelectable="false" Repeatable="Week" Date="7/11/2008" /> 
    </SpecialDays> 
</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:

<telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
 
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
    <script type="text/javascript"
        function RadCalendar1_DateClick(sender, args) { 
            var day = args.get_renderDay(); 
            var isWeekend = day.get_isWeekend(); 
            if(!isWeekend) { 
                // unselect the day 
                day.Select(false); 
                 
                // cancel the DateClick event 
                args.set_cancel(true); 
            }            
        } 
    </script> 
</telerik:RadScriptBlock>        
 
<telerik:RadCalendar ID="RadCalendar1" runat="server" > 
    <ClientEvents OnDateClick="RadCalendar1_DateClick" />    
</telerik:RadCalendar> 

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

Regards,
Kevin Babcock
0
Jatin
Top achievements
Rank 1
answered on 29 May 2009, 10:13 AM
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 
            RadCalNextDateSelection.SpecialDays.Add(e.Day)  
        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?


 

0
Yavor
Telerik team
answered on 01 Jun 2009, 11:20 AM
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.

Regards,
Yavor
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.
0
Jeppe
Top achievements
Rank 1
answered on 23 Sep 2009, 08:24 AM
Hi

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?
0
Yavor
Telerik team
answered on 28 Sep 2009, 05:26 AM
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:

http://demos.telerik.com/aspnet-ajax/calendar/examples/functionality/specialdays/defaultcs.aspx

I hope it gets you started properly!

All the best,
Yavor
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.
Tags
Calendar
Asked by
KMF
Top achievements
Rank 1
Answers by
Kevin Babcock
Top achievements
Rank 1
Jatin
Top achievements
Rank 1
Yavor
Telerik team
Jeppe
Top achievements
Rank 1
Share this question
or