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

Sys & Telerik undefined when ObjectDataSource used with RadScheduler

7 Answers 83 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Lars-Erik
Top achievements
Rank 1
Lars-Erik asked on 21 Jun 2011, 09:47 AM

Hi!

I'm trying to reproduce the resource availability demo using ObjectDataSources instead. Trying to build the code from scratch to get to know the component. As soon as I set DataSourceId referencing an ObjectDataSource on either the Scheduler or a ResourceType the scripts from WebResource is not included in the page. Before I add the datasource, two scripts are loaded and it checks whether Sys is undefined, but when the datasource is set, the scripts are not there and it just attempts to start the initialization.
I use the Q1 2011 version.

Any ideas?
Here's the code:
(If you remove DataSourceID, GroupBy and ResourceTypes, it works fine, otherwise scripts is not loaded)

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Scheduler.aspx.cs" Inherits="TelerikPrototyping.Scheduler" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
     
    <telerik:RadScriptManager runat="server" ID="RadScriptManager" >
         
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadScheduler" LoadingPanelID="RadAjaxLoadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel" />
 
    <asp:ObjectDataSource runat="server"
        ID="EntriesDataSource"
        TypeName="TelerikPrototyping.Scheduler"
        SelectMethod="GetEntries"
        OnObjectCreating="OnDataSourceCreating"
        DataObjectTypeName="TelerikPrototyping.SchedulerEntry, Telerik.Calendar"
    />
     
    <asp:ObjectDataSource runat="server"
        ID="RoomsDataSource"
        TypeName="TelerikPrototyping.Scheduler"
        SelectMethod="GetRooms"
        OnObjectCreating="OnDataSourceCreating"
        DataObjectTypeName="TelerikPrototyping.Room, Telerik.Calendar"
    />
     
    <div>
        <telerik:RadScheduler runat="server"
            ID="RadScheduler"
            DataKeyField="Id"
            DataSubjectField="Subject"
            DataStartField="Start"
            DataEndField="End"
            HoursPanelTimeFormat="HH:mm"
            GroupBy="Rooms"
            DataSourceID="EntriesDataSource"
            >
            <ResourceTypes>
                <telerik:ResourceType DataSourceID="RoomsDataSource" KeyField="Id" ForeignKeyField="RoomId" TextField="Name" Name="Rooms" />
            </ResourceTypes>
        </telerik:RadScheduler>
    </div>
    </form>
</body>
</html>

 

using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
 
namespace TelerikPrototyping
{
    public partial class Scheduler : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void OnDataSourceCreating(object sender, ObjectDataSourceEventArgs e)
        {
            e.ObjectInstance = this;
        }
 
        public List<SchedulerEntry> GetEntries()
        {
            return GetSessionList("entries", new SchedulerEntry("test", DateTime.Today.AddHours(13), DateTime.Today.AddHours(14), GetRooms()[0].Id, new Guid[0]));
        }
 
        public List<Room> GetRooms()
        {
            return GetSessionList("rooms", new Room("Rom 1"), new Room("Rom 2"), new Room("Rom3"));
        }
 
        public List<Person> GetPersons()
        {
            return GetSessionList("persons", new Person("Ola"), new Person("Kari"), new Person("Per"));
        }
  
        private List<T> GetSessionList<T>(string key, params T[] initial)
            where T : class
        {
            if (Session[key] == null)
                Session[key] = new List<T>(initial);
            return (List<T>) Session[key];
        }
    }
 
    public class SchedulerEntry
    {
        public Guid Id { get; private set; }
        public string Subject { get; private set; }
        public DateTime Start { get; private set; }
        public DateTime End { get; private set; }
 
        public Guid RoomId { get; private set; }
        public Guid[] PersonIds { get; private set; }
 
        public SchedulerEntry()
        {
             
        }
 
        public SchedulerEntry(Guid id, string subject, DateTime start, DateTime end, Guid roomId, Guid[] personIds)
        {
            Id = id;
            Subject = subject;
            Start = start;
            End = end;
            RoomId = roomId;
            PersonIds = personIds;
        }
 
        public SchedulerEntry(string subject, DateTime start, DateTime end, Guid roomId, Guid[] personIds)
        {
            Id = Guid.NewGuid();
            Subject = subject;
            Start = start;
            End = end;
            RoomId = roomId;
            PersonIds = personIds;
 
        }
    }
 
    public class Room
    {
        public Guid Id { get; private set; }
        public string Name { get; private set; }
 
        public Room(Guid id, string name)
        {
            Id = id;
            Name = name;
        }
 
        public Room(string name)
        {
            Id = Guid.NewGuid();
            Name = name;
        }
 
        public Room()
        {
             
        }
    }
 
    public class Person
    {
        public Guid Id { get; private set; }
        public string Name { get; private set; }
 
        public Person(Guid id, string name)
        {
            Id = id;
            Name = name;
        }
 
        public Person(string name)
        {
            Id = Guid.NewGuid();
            Name = name;
        }
    }
 
}

Never mind the Session state of the data sources - that will change when everything works. ;)

Lars-Erik

7 Answers, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 24 Jun 2011, 09:42 AM
Hello Lars-Erik,

Unfortunately the provided information is not enough to be able to advice you anything.

Could you please send me your code so I can inspect it and help you? Thank you!

P.S: Please note that this is a fourm post and you are not able to attach files. As an alternative you can use one of the sites for free online storage as 4shared.com.

Kind regards,
Veronica Milcheva
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.

0
Lars-Erik
Top achievements
Rank 1
answered on 24 Jun 2011, 09:59 AM
We tested this code on two computers, and it behaves equally..

http://dl.dropbox.com/u/17415256/SchedulerPrototyping.zip


Lars-Erik
0
Lars-Erik
Top achievements
Rank 1
answered on 28 Jun 2011, 09:14 AM
Had a chance to reproduce?

L-E
0
Veronica
Telerik team
answered on 30 Jun 2011, 08:33 AM
Hello Lars-Erik,

Thank you for the attached project.

Yes, I've been able to reproduce the issue however even with commented GroupBy and ResourceTypes I am still getting an error "Sys is undefined" and "Telerik is undefined". That makes me think that your web application is not configured to work with AJAX.

Please take a look at this blog post and this "General Troubleshooting" help article and let me know if this helps.

Regards,
Veronica Milcheva
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.

0
Lars-Erik
Top achievements
Rank 1
answered on 30 Jun 2011, 08:36 AM
I have read those, and I've used the smart-tag helper on the radscriptmanager to edit web.config.
It works if you also comment out the datasource. (Then the scripts are loaded)

Please have a look at the zip file linked to in my earlier post and see if you can spot anything missing?
The web.config file is in there..

Lars-Erik
0
Lars-Erik
Top achievements
Rank 1
answered on 30 Jun 2011, 10:23 AM
Hi again!

We managed to pinpoint the source of the error.
It works as soon as we don't set the objectdatasources instance to the page instance. (The OnDataSourceCreating event)
This is something that is part of our general architecture choice (MVP) and should definately not affect UI components.

Edit:
My colleague just managed to make it work by moving everything into a usercontrol.
Please consider this a bug report.
(Using an ObjectDataSource having instance set to the Page instance with the Scheduler component)

Lars-Erik
0
Veronica
Telerik team
answered on 06 Jul 2011, 09:14 AM
Hello Lars-Erik,

Thank you for your cooperation.

I'm glad that you found a workaround on your own. We'll do the needful to investigate and find where is the problem.

Best wishes,
Veronica Milcheva
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Scheduler
Asked by
Lars-Erik
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Lars-Erik
Top achievements
Rank 1
Share this question
or