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

Specialday not disabled in other month

8 Answers 108 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 2
Marco asked on 23 Sep 2011, 01:06 AM

Hello All,

I have a very simple Calendar with 2 months, Sep and Oct
The SpecialDay is Oct first an must be only visible on the second month in the calendar.
So far so good.

 

In the first month of the calendar this date is not visible as a SpecialDay but when I hover over the date then the date lights-up while it must be disabled and when hover-off then the style is applied from the special date.

 

The screen dump’s show before hover and after hover.

 

I set the date on DayRender and compare the date to e.Day and the Month.

The tooltip is only visible on the second calendar month so I know the a have the correct day and month.

 

How can I disable the days form the other months without setting the property ShowOtherMonthsDays="false" ?

<head runat="server">
    <title></title>
    <style type="text/css">
        .RadCalendar .event_future
        {
            border: 1px solid Green !important;
            background-color: Lime;
        }
        .RadCalendar .rcOtherMonth a, .RadCalendar .riDisabled a
        {
            cursor: default;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
        <telerik:RadCalendar ID="RadCalendar1" runat="server" CultureInfo="nl-NL" EnableMultiSelect="False"
            EnableMonthYearFastNavigation="False" FirstDayOfWeek="Monday" MultiViewRows="2"
            TitleFormat="MMM" ShowDayCellToolTips="false" Skin="WebBlue" TitleAlign="Center" 
            UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False">
        </telerik:RadCalendar>
    </form>
</body>
</html>

 

Protected Sub RadCalendar1_DayRender(sender As Object, e As Telerik.Web.UI.Calendar.DayRenderEventArgs) Handles RadCalendar1.DayRender
    Dim SpecialDay As Date = DateValue("1-10-2011")
    If e.Day.Date = SpecialDay AndAlso e.View.MonthStartDate.Month = SpecialDay.Month Then
        e.Day.IsSelectable = True
        e.Day.IsDisabled = False
        e.Cell.ToolTip = "SpecialDay"
        e.Cell.CssClass = "event_future"
    Else
        e.Day.IsSelectable = False
        e.Day.IsDisabled = True
        e.Cell.CssClass = "riDisabled"
    End If
    Me.RadCalendar1.SpecialDays.Add(e.Day)
End Sub

 

 

 

Best regards,

 

Marco

8 Answers, 1 is accepted

Sort by
0
Marco
Top achievements
Rank 2
answered on 23 Sep 2011, 12:38 PM

I have made some adjustments

 

Multiple Special days are now in a list.

Al the special days are now visible but the overlapping dates are not selectable.

I think it have something to do that a e.Day is not unique per month on client-side.
Is this a bug?

 

Protected Sub RadCalendar1_DayRender(sender As Object, e As Telerik.Web.UI.Calendar.DayRenderEventArgs) Handles RadCalendar1.DayRender
    If DateList.Contains(e.Day.Date) AndAlso e.View.MonthStartDate.Month = e.Day.Date.Month Then
        e.Cell.ToolTip = "SpecialDay"
        e.Cell.CssClass = "event_future"
    Else
        e.Day.IsSelectable = False
        e.Day.IsDisabled = True
        Me.RadCalendar1.SpecialDays.Add(e.Day)
    End If
End Sub
Protected Sub RadCalendar1_PreRender(sender As Object, e As EventArgs) Handles RadCalendar1.PreRender
    DateList = New List(Of Date)
    Dim StartDate As Date = Me.RadCalendar1.CalendarView.ViewStartDate.AddDays(-15)
    Dim EndDate As Date = Me.RadCalendar1.CalendarView.ViewEndDate.AddDays(15)
    Dim SpecialDay As Integer
    For SpecialDay = StartDate.ToOADate To EndDate.ToOADate Step 3
        DateList.Add(Date.FromOADate(SpecialDay))
    Next
End Sub
0
Andrey
Telerik team
answered on 28 Sep 2011, 11:34 AM
Hello Marco,

Please try this code and check whether the issue is resolved:
Protected Sub RadCalendar1_DayRender(sender As Object, e As Telerik.Web.UI.Calendar.DayRenderEventArgs) Handles RadCalendar1.DayRender
Dim NewDay As New RadCalendarDay(RadCalendar1)
        NewDay.Date = New DateTime(2010, 11, 12)       
        If e.Day.Date = SpecialDay.Date Then
    'e.Day.IsSelectable = true;
    'e.Day.IsDisabled = false;
    e.Cell.ToolTip = "SpecialDay"
    e.Cell.CssClass = "event_future"
Else
    'e.Day.IsSelectable = false;
    'e.Day.IsDisabled = true;
    e.Cell.CssClass = "riDisabled"
End If
Me.RadCalendar1.SpecialDays.Add(e.Day)
End Sub

Otherwise, please give a detailed explanation about what are you trying to achieve.

Greetings,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Marco
Top achievements
Rank 2
answered on 28 Sep 2011, 11:50 AM
Dear Andrey,

The problem is with the overlapping date's from the first calendar en the second.
Months in the calendar are september and october MultiViewRows="2", change the date to

New

DateTime(2011, 10, 1) 

and do

If

e.Day.Date = NewDay.Date AndAlso e.Day.Date.Month = e.View.MonthStartDate.Month Then

 

When you look you see that only on date is selected in the second month and thats correct
But when you hover over the date in the month of september then it is selecable and more importanly after the hover the style event_future is applyed.

What i think that there is no unique id on client-side within each month.

Thanks,

Marco
0
Princy
Top achievements
Rank 2
answered on 28 Sep 2011, 02:29 PM
Hello Marco,

Check the following forum thread which implements a similar scenario.
disabling calendar weekend days .

Thanks,
Princy.
0
Andrey
Telerik team
answered on 28 Sep 2011, 04:55 PM
Hi Marco,

Try using the following code and check whether the result is satisfactory:
Protected Sub RadCalendar1_DayRender(sender As Object, e As Telerik.Web.UI.Calendar.DayRenderEventArgs)
    Dim SpecialDay As New RadCalendarDay(RadCalendar1)
    SpecialDay.Date = New DateTime(2011, 10, 1)
    If e.Day.[Date] = SpecialDay.Date AndAlso e.View.MonthStartDate.Month = SpecialDay.Date.Month Then
        'e.Day.IsSelectable = true;
        'e.Day.IsDisabled = false;
        e.Cell.ToolTip = "SpecialDay"
        e.Cell.CssClass = "event_future"
 
        Me.RadCalendar1.SpecialDays.Add(SpecialDay)
    ElseIf e.Day.Date = SpecialDay.Date AndAlso e.View.MonthStartDate.Month <> SpecialDay.Date.Month Then
        'e.Day.IsSelectable = false;
        'e.Day.IsDisabled = true;
        e.Cell.Attributes.Add("onmouseover", "mouseOver(this)")
        e.Cell.Attributes.Add("onmouseout", "mouseOut(this)")
        e.Cell.CssClass = "riDisabled"
    End If
End Sub

And in the aspx page:
function mouseOver(sender) {
            setTimeout(function () {
                sender.className = "rcOtherMonth rcHover";
            }, 10);
        }
        function mouseOut(sender) {
            setTimeout(function () {
                sender.className = "rcOtherMonth";
            }, 10);
        }


All the best,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Marco
Top achievements
Rank 2
answered on 28 Sep 2011, 06:15 PM
Hi Andrey,

Form a visual point of view it works but you can not set e.Day.IsSelectable = False and e.Day.IsDisabled = True al the dates are now clickable and when you click the date in the correct month then there are 2 date’s selected after the postback

Best regards Marco

0
Andrey
Telerik team
answered on 29 Sep 2011, 09:40 AM
Hi Marco,

By default all items are clickable and enabled, information how this behavior could be overrided you could find from this forum thread.

All the best,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Marco
Top achievements
Rank 2
answered on 29 Sep 2011, 12:50 PM
Hi Andrey,

I know that and did that, I would say try it in combination with the code you send me 
e.Cell.Attributes.Add("onmouseover", "mouseOver(this)")
e.Cell.Attributes.Add("onmouseout", "mouseOut(this)")

And then it doesn't work any more.
Leave the attributes out if it and the disableling works but not the mouse over css problem and visav-ersa

What I have figurerd out that this must be a bug when you use more then 1 calendar.
I have made my own control, what looks and handles the same like yours with the exeption that every calendar is treated as it's own and then it works.

Regards,

Marco
Tags
Calendar
Asked by
Marco
Top achievements
Rank 2
Answers by
Marco
Top achievements
Rank 2
Andrey
Telerik team
Princy
Top achievements
Rank 2
Share this question
or