Order of Events for Cell Formating

2 posts, 0 answers
  1. Denis Cilliers
    Denis Cilliers avatar
    62 posts
    Member since:
    Jan 2004

    Posted 20 Dec 2012 Link to this post

    Hi There

    I'm having some trouble with the order of events for the Cell Format

    We do some conditional cell formatting based on values returned from a database, such as what days to block - holidays etc
    I managed to get it to work fine the first time round 

    The issue arises on the following Navigator events
    • NavigateBackwardsClick
    • NavigateForwadsClick
    as the following event fires before the Navigate event
    • Scheduler.CellFormating
    This seems quite strange, I would have thought that they would be reversed.

    How can I call a refresh of the data method and which event should it go in 
    • exceptionTimes = _service.GetSchedulerExceptionTimesByDateRange(RangeStartDate, RangeEndDate)

    As putting the values in the Navigate events makes the cellformating event use the previous 
    range of exception times for the previous date range as defined before the navigate event.

    Below is some example code 
    Private Sub snMain_NavigateBackwardsClick(sender As Object, e As EventArgs) Handles snMainNav.NavigateBackwardsClick
        RangeStartDate = rsScheduler.ActiveView.StartDate.AddDays(-1)
        RangeEndDate = rsScheduler.ActiveView.EndDate.AddDays(1)
        exceptionTimes = GetSchedulerExceptionTimesByDateRange(, RangeStartDate, RangeEndDate)
     End Sub
    Private Sub rsScheduler_CellFormatting(sender As Object, e As SchedulerCellEventArgs) Handles rsScheduler.CellFormatting
        ' Other Code
        For Each Exception In exceptionTimes
            'Block etc
    End Sub

  2. Ivan Todorov
    Ivan Todorov avatar
    688 posts

    Posted 21 Dec 2012 Link to this post

    Hello Denis,

    Thank you for contacting us.

    The NavigateBackwardsClick fires after the view has been updated and the CellFormatting event fires during the update itself. Also, the NavigateBackwardsClick fires only when using the navigation buttons in RadSchedulerNavigator and will not cover cases when navigating using keyboard for example. Therefore, I would suggest using the PropertyChanged event of the active view. The following code snippet demonstrates this approach:
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        AddHandler Me.RadScheduler1.ActiveView.PropertyChanged, AddressOf ActiveView_PropertyChanged
        AddHandler Me.RadScheduler1.ActiveViewChanging, AddressOf RadScheduler1_ActiveViewChanging
        AddHandler Me.RadScheduler1.ActiveViewChanged, AddressOf RadScheduler1_ActiveViewChanged
    End Sub
    Private Sub RadScheduler1_ActiveViewChanging(sender As System.Object, e As Telerik.WinControls.UI.SchedulerViewChangingEventArgs)
        RemoveHandler Me.RadScheduler1.ActiveView.PropertyChanged, AddressOf ActiveView_PropertyChanged
    End Sub
    Private Sub RadScheduler1_ActiveViewChanged(sender As System.Object, e As Telerik.WinControls.UI.SchedulerViewChangedEventArgs)
        AddHandler Me.RadScheduler1.ActiveView.PropertyChanged, AddressOf ActiveView_PropertyChanged
    End Sub
    Private Sub ActiveView_PropertyChanged(sender As Object, e As System.ComponentModel.PropertyChangedEventArgs)
        If e.PropertyName = "StartDate" Then
            'get exception times
        End If
    End Sub

    I hope you find this useful. Should you have any additional questions, do not hesitate to ask.

    Kind regards,
    Ivan Todorov
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Back to Top