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
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 IfEnd SubProtected 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)) NextEnd SubPlease 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 IfMe.RadCalendar1.SpecialDays.Add(e.Day)End SubOtherwise, please give a detailed explanation about what are you trying to achieve.
Greetings,
Andrey
the Telerik team
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 doIf
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
Check the following forum thread which implements a similar scenario.
disabling calendar weekend days .
Thanks,
Princy.
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 IfEnd SubAnd 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
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
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
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