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">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
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