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

Issue with Scheduler Rebinding

1 Answer 165 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
eric knight
Top achievements
Rank 1
eric knight asked on 08 Feb 2008, 04:05 PM
Hello,

Currently we are using the Scheduler in a Compostie Control. The scheduler is being built dynamically in the CreateChildControls method as such:

        Controls.Clear();  
 
            Panel pnl = new Panel();              
 
            _scheduler = new Telerik.Web.UI.RadScheduler();  
            _scheduler.ID = "scheduler1";  
 
            //add server events  
            _scheduler.NavigationCommand += new SchedulerNavigationCommandEventHandler(Scheduler_NavigationCommand);  
            _scheduler.AppointmentDataBound += new AppointmentDataBoundEventHandler(Scheduler_AppointmentDataBound);  
            _scheduler.AppointmentCommand += new AppointmentCommandEventHandler(Scheduler_AppointmentCommand);  
            _scheduler.NavigationComplete += new SchedulerNavigationCompleteEventHandler(Scheduler_NavigationComplete);  
            _scheduler.AppointmentUpdate += new AppointmentUpdateEventHandler(Scheduler_AppointmentUpdate);  
            _scheduler.AppointmentCreated += new AppointmentCreatedEventHandler(Scheduler_AppointmentCreated);  
 
            //add client events  
            _scheduler.OnClientAppointmentClick = "AppointmentEditing";  
            _scheduler.OnClientRecurrenceActionDialogShowing = "RecurrenceActionDialogShowingHandler";  
            _scheduler.OnClientTimeSlotClick = "AppoinmentAdding";  
            _scheduler.MonthVisibleAppointmentsPerDay = 5;  
              
            //SetViewType(_scheduler);  
              
            SetSkin(_scheduler, CalendarSkin);            
            _scheduler.ShowFullTime = true;  
            _scheduler.StartEditingInAdvancedForm = false;  
            _scheduler.StartInsertingInAdvancedForm = false;      
            //_scheduler.WeekHeaderDateFormat = WeekHeaderFormat;  
            //_scheduler.MonthHeaderDateFormat = MonthHeaderFormat;  
            _scheduler.OverflowBehavior = OverflowBehavior.Expand;  
            _scheduler.DataSource = this.EventData;  
            _scheduler.DataKeyField = EventCalendar.ID;  
            _scheduler.DataSubjectField = EventCalendar.Title;  
            _scheduler.DataStartField = EventCalendar.StartDTm;  
            _scheduler.DataEndField = EventCalendar.EndDTm;  
            _scheduler.DataRecurrenceField = EventCalendar.RecurrencePattern;  
            _scheduler.DataRecurrenceParentKeyField = EventCalendar.RecurringParentID;  
 
            _scheduler.DataBind();  
 
            pnl.Controls.Add(_scheduler);  
            Controls.Add(pnl); 

This routine gets called everytime (initial load and postbacks).

This works prefectly fine, data loads properly, so far so good. The problem occurs when we try to navigate to a different SchedulerViewType

In the NavigationComplete method we have the following code:
        protected void Scheduler_NavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e)  
        {  
            _scheduler.Rebind();  
        } 


When the NavigationComplete method is hit, the following error occurs:
Unable to cast object of type 'Telerik.Web.UI.Scheduler.Rendering.DayView' to type 'Telerik.Web.UI.Scheduler.Rendering.MonthView'.

What I am looking for is a best practices for using Scheduler.Rebind(), specifically where and when it should be used in this instance.

Any insight would be greatly appreciated.

Thank you

1 Answer, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 08 Feb 2008, 06:01 PM
Hello Eric,

The Rebind method does three things:
  1. Marks the control data as "dirty". It will try to reread its data from the data source at the first suitable moment in the control's life cycle.
  2. Hides any active insert or edit form.
  3. Clears any child controls that might have been created for the currently selected view type.
It should be used when the data in the underlying data source has been changed by some other operation or by a different instance. This approach is demonstrated in the multiple instances example.

The other case in which Rebind is useful is when you want to change the view type (or selected date) late in the page's life cycle. For example, you might need to change the view type in the PreRenderComplete event.

I do not think that you need it in your scenario. If you create the RadScheduler instance every time it should be able to process its post-back commands and update its state accordingly.

Regards,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Scheduler
Asked by
eric knight
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Share this question
or