Replacing SchedulerInfo in ResourcesPopulating not working

2 posts, 0 answers
  1. David Bryant
    David  Bryant avatar
    19 posts
    Member since:
    Jan 2006

    Posted 28 Jan 2011 Link to this post

    I using a web service to bind the scheduler and now trying to populate the resources.  I need to pass some additional info to the web service so I've created a class that implements ISchedulerInfo and have followed the instructions for passing additional info to the web service via a custom implementation of ISchedulerInfo.  I'm successful with the call to GetAppointments with additional parameters but I set the custom parameters in javascript. 

    So, the web service settings show ResourcePopulationMode="ServerSide".  On the page...

        Protected Sub RadScheduler1_ResourcesPopulating(ByVal sender As Object, ByVal e As Telerik.Web.UI.ResourcesPopulatingEventArgs)
            Dim myInfo As New CustomSchedulerInfo
            myInfo.UserID = 1234
            e.SchedulerInfo = myInfo
        End Sub

    Setting breakpoints shows ResourcePopulating firing before the web method call to GetResources. 

        <WebMethod()> _
        Public Function GetResources(ByVal schedulerInfo As CustomSchedulerInfo) As IEnumerable(Of ResourceData)
            Return Controller.GetResources(schedulerInfo)
        End Function

    When I set a breakpoint in GetResources and evaluate schedulerInfo, schedulerInfo.UserID = 0 (default). 

    Maybe I'm just missing some setting but it appears as though replacing e.SchedulerInfo is not working -- at least not in VB.

    Any suggestions?
  2. Peter
    Peter avatar
    6637 posts

    Posted 02 Feb 2011 Link to this post

    Hi David,

    For your convenience, I have prepared a simple working demo which shows how to bind RadScheduler to a Web Service and how to filter appointments based on a selected resource. Here is the code with highlighted relevant sections:

    Copy Code
    public class MySchedulerInfo : SchedulerInfo
        public string TeacherID { get; set; }
        public MySchedulerInfo(ISchedulerInfo baseInfo, string teacherID)
            : base(baseInfo)
            TeacherID = teacherID;
        public MySchedulerInfo()

    Copy Code
        public IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)
            return Controller.GetAppointments(schedulerInfo);
        public IEnumerable<AppointmentData> InsertAppointment(MySchedulerInfo schedulerInfo, AppointmentData appointmentData)
            return Controller.InsertAppointment(schedulerInfo, appointmentData);
        public IEnumerable<AppointmentData> UpdateAppointment(MySchedulerInfo schedulerInfo, AppointmentData appointmentData)
            return Controller.UpdateAppointment(schedulerInfo, appointmentData);
        public IEnumerable<AppointmentData> CreateRecurrenceException(MySchedulerInfo schedulerInfo, AppointmentData recurrenceExceptionData)
            return Controller.CreateRecurrenceException(schedulerInfo, recurrenceExceptionData);
        public IEnumerable<AppointmentData> RemoveRecurrenceExceptions(MySchedulerInfo schedulerInfo, AppointmentData masterAppointmentData)
            return Controller.RemoveRecurrenceExceptions(schedulerInfo, masterAppointmentData);
        public IEnumerable<AppointmentData> DeleteAppointment(MySchedulerInfo schedulerInfo, AppointmentData appointmentData, bool deleteSeries)
            return Controller.DeleteAppointment(schedulerInfo, appointmentData, deleteSeries);
        public IEnumerable<ResourceData> GetResources(MySchedulerInfo schedulerInfo)
            return Controller.GetResources(schedulerInfo);


    Copy Code
    <script type="text/javascript">
           //Put your JavaScript code here.
           var teacherID = "all";
           function OnClientSelectedIndexChanged(sender, args) {
               teacherID = args.get_item().get_value();
               var scheduler = $find('<%=RadScheduler1.ClientID %>');
           function OnClientAppointmentsPopulating(sender, eventArgs) {
               eventArgs.get_schedulerInfo().TeacherID = teacherID;
           Filter appointments by teacher (resource):
           <telerik:RadComboBox ID="RadComboBox1" runat="server" OnClientSelectedIndexChanged="OnClientSelectedIndexChanged">
                   <telerik:RadComboBoxItem Text="All" Value="all" />
                   <telerik:RadComboBoxItem Text="Teacher 1" Value="1" />
                   <telerik:RadComboBoxItem Text="Teacher 2" Value="2" />
       <telerik:RadScheduler ID="RadScheduler1" runat="server" OnClientAppointmentsPopulating="OnClientAppointmentsPopulating"
           AppointmentStyleMode="Default" SelectedView="WeekView" SelectedDate="2011-01-21" Width="600px">
           <WebServiceSettings Path="SchedulerWebService.asmx" ResourcePopulationMode="ServerSide" />
               <telerik:ResourceStyleMapping Type="Teacher" Key="1" BackColor="Orange" />
               <telerik:ResourceStyleMapping Type="Teacher" Key="2" BackColor="Aqua" />

    Copy Code
    public override IEnumerable<Appointment> GetAppointments(ISchedulerInfo shedulerInfo)
            var myInfo = shedulerInfo as MySchedulerInfo;
            string teacherID = myInfo.TeacherID;
            List<Appointment> appointments = new List<Appointment>();
            using (DbConnection conn = OpenConnection())
                DbCommand cmd = DbFactory.CreateCommand();
                cmd.Connection = conn;
                cmd.CommandText = "SELECT [ClassID], [Subject], [Start], [End], [RecurrenceRule], [RecurrenceParentId], [Reminder] FROM [DbProvider_Classes]";
                if (teacherID != "all")        
                    cmd.CommandText += "WHERE TeacherID = " + teacherID;

    Peruse it at leisure and don't hesitate to contact us if you need further guidance. We will be glad to help.

    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top