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

Adding SpecialDays by range

4 Answers 98 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Sébastien
Top achievements
Rank 2
Sébastien asked on 27 Jan 2009, 10:37 AM
Hello Telerik's Team !

I wanted to add SpecialDays with method AddRange(Array of RadCalendarDays) but it don't seems to fully work. Maybe i'm missing something ? I'm using DotNetNuke, and I'm trying to show on the calendar the days which contain an event.
If you look on my screenshots, the orange days are those with event. So the SpecialDays method works fine, but for the event planned on the 28 January, it only appears if I move to February then come back to January. For more, in debug many others days are added to the List(of RadCalendarDay) but they doesn't appear on the calendar. I've also tryed the SpecialDays.Add() and many many other tricks ...

- 28 January event doesn't appear : http://88.191.55.88/Screenshot-20090127-113340.png
- I move to February : http://88.191.55.88/Screenshot-20090127-113424.png
- Then come back to January : http://88.191.55.88/Screenshot-20090127-113444.png


 <telerik:RadCalendar ID="radCalSearch" runat="server" EnableMultiSelect="true" EnableNavigationAnimation="false" 
        FastNavigationNextImage="~/images/btn_RadCal_FN.jpg" 
        FastNavigationPrevImage="~/images/btn_RadCal_FP.jpg" 
        NavigationNextImage="~/images/btn_RadCal_N.jpg" 
        NavigationPrevImage="~/images/btn_RadCal_P.jpg" 
        ShowRowHeaders="true" DayNameFormat="FirstTwoLetters"  > 
        <SpecialDays> 
            <telerik:RadCalendarDay Date="" Repeatable="Today"
                <ItemStyle CssClass="radCalToday_Default" /> 
            </telerik:RadCalendarDay> 
        </SpecialDays> 
    </telerik:RadCalendar> 
 Private Sub Page_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load 
 
            Try 
                If (Page.IsPostBack = FalseThen 
 
                    [...] 
 
                    SetExistingDates() 
 
                End If 
 
            Catch exc As Exception    'Module failed to load 
                ProcessModuleLoadException(Me, exc) 
            End Try 
 
        End Sub 
  Private Sub SetExistingDates() 
 
            Dim objArticleController As New ArticleController 
            Dim objArtList As List(Of ArticleInfo) = objArticleController.GetArticleList(intSourceModuleId, True
            Dim objExistingDates As New List(Of Telerik.Web.UI.RadCalendarDay) 
 
            For Each objArticle As ArticleInfo In objArtList 
                If objArticle.EventStartDate <> Null.NullDate Then 
                    ' we have an event, displaying the startDate 
                    Dim objDate As New Telerik.Web.UI.RadCalendarDay 
                    objDate.Date = objArticle.EventStartDate 
                    objDate.ItemStyle.CssClass = "radCalDefault_Default radCalDefault_EventDay" ' Set CssClass to the day 
                    If Not ExistingDateIsNotAlreadyOnTheCollection(objExistingDates, objDate.DateThen 
                        objExistingDates.Add(objDate) ' Add the specialDay into List 
                    End If 
 
                    If objArticle.EventEndDate <> Null.NullDate Then 
                        ' we have a endDate, we display all the days between Start and End. 
                        If objArticle.EventStartDate < objArticle.EventEndDate Then ' should be unusefull 
                            While objDate.Date < objArticle.EventEndDate.Date 
                                objDate.Date = objDate.Date.AddDays(1) ' Next day 
                                If Not ExistingDateIsNotAlreadyOnTheCollection(objExistingDates, objDate.DateThen 
                                    objExistingDates.Add(objDate) 
                                End If 
                            End While 
                        End If 
                    End If 
                Else 
 
                End If 
 
            Next 
 
            If Not objExistingDates Is Nothing Then 
                Me.radCalSearch.SpecialDays.AddRange(objExistingDates.ToArray) 
            End If 
 
 
        End Sub 
 

S├ębastien


4 Answers, 1 is accepted

Sort by
0
Sébastien
Top achievements
Rank 2
answered on 27 Jan 2009, 03:39 PM
Ok I get it to work. I don't know why, but the RadCalendarDay object, once added to the collection, refuse to change his property .Date. You have to recreate a new object for each date.

Cheers,

Seb
0
Sébastien
Top achievements
Rank 2
answered on 27 Jan 2009, 03:44 PM
But it didn't solved the bug where some specialDays are viewable only after a click on NextNavigation ...
Is it an issue ?
0
Georgi Krustev
Telerik team
answered on 30 Jan 2009, 10:59 AM
Hello Fichot,

To apply the right css class on initial load, you need to delete the underscored line from the custom css class name. In your case you can name the custom class  like that radCalTodayDefault. Thus the css class will be applied on first page load.

You can change the date to some of the SpecialDays in the collection.

Here is a code snippet which I am using to change the date of the first Special day:
    Protected Sub Button1_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles Button1.Click 
        If radCalSearch.SpecialDays.Count > 0 Then 
            radCalSearch.SpecialDays(0).Date = DateTime.Now.AddDays(-10) 
        End If 
    End Sub 

I hope this helps.

All the best,
Georgi Krustev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Sébastien
Top achievements
Rank 2
answered on 30 Jan 2009, 11:22 AM
Thanks for the trick ! It works perfectly.

Seb
Tags
Calendar
Asked by
Sébastien
Top achievements
Rank 2
Answers by
Sébastien
Top achievements
Rank 2
Georgi Krustev
Telerik team
Share this question
or