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

No resource found in appointmentinsert

5 Answers 45 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Yang Qu
Top achievements
Rank 1
Yang Qu asked on 28 Apr 2010, 06:55 AM
Hello,

I am trying to access selected resource key from appointmentInsert event, but it returns null.
e.Appointment.Resources.GetResourceByType("Scheduler.Room") 

By debugging the code, I found the e.Appointment.Resources is empty, but I can see my resources are loaded in the inserting form.
The inserting form is a customized form downloaded from telerik website.

Anyone can help me with this?

5 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 29 Apr 2010, 02:56 PM
Hello Yang,

What is your resource type name? Have you tried the following:
e.Appointment.Resources.GetResourceByType("Room") ?


All the best,
Peter
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ilona
Top achievements
Rank 1
answered on 05 Jul 2010, 10:45 AM
Hi,

I have the same problem, when inserting or deleting an appointment it has no resources.
I do see the resources in de dropdownlist.

Code for updating:

public

 

void CopyInfo(Appointment source)

 {

    Subject = source.Subject;    

    Start = source.Start;

    End = source.End;

    RecurrenceRule = source.RecurrenceRule;

 

 

    if (source.RecurrenceParentID != null)

     {

         RecurrenceParentId = source.RecurrenceParentID.ToString();

    }

 

 

    Resource playlist = source.Resources.GetResourceByType("Playlist");

 

    PlaylistId = (

int)playlist.Key;

 

 

     AppointmentColor = source.Attributes[

"AppointmentColor"];

 

 

 

}

Code for creating the resource "Playlist":

 

ResourceType resType = new ResourceType("Playlist");

 

 

resType.AllowMultipleValues =

false;

 

 

resType.KeyField =

"PlaylistId";

 

 

resType.TextField =

"Playlist";

 

 

resType.ForeignKeyField =

"PlaylistId";

 

 

RadScheduler1.ResourceTypes.Add(resType);

 

 

 

 

 

List<Playlist> playlistList = new List<Playlist>(Playlist.GetAllPlaylists());

 

 

 

 

foreach (Playlist playlist in playlistList)

{

 

    Resource resPlaylist = new Resource();

 

 

    resPlaylist.Available =

true;

 

 

    resPlaylist.Key = playlist.Id;

    resPlaylist.Text = playlist.Name;

    resPlaylist.Type =

"Playlist";

 

 

 

    RadScheduler1.Resources.Add(resPlaylist);

}

 

Am I missing something?

 

 

0
Peter
Telerik team
answered on 05 Jul 2010, 02:28 PM
Hello Ilona,

Best practise for such cases is to define an AppointmentInfo class and use it to populate RadScheduler as in the Binding to Generic List demo.


Greetings,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ilona
Top achievements
Rank 1
answered on 05 Jul 2010, 03:29 PM
Hi,

The demo you mentioned is the one I've copied, so I have an AppointmentInfo class for databinding.
I've noticed that I can get the data by getting an attribute instead of getting the resource:

This doesn't work:

Resource playlist = source.Resources.GetResourceByType("Playlist");


And this does:

PlaylistId =

source.Attributes["PlaylistId"];

But I've defined the "PlaylistId" as a resource, as shown in my previous post.

 

0
Peter
Telerik team
answered on 07 Jul 2010, 02:21 PM
Hello Ilona,

The AppointmentInfo class from the online demo accommodates a User resource. For any other type of resource you will need to modify the AppointmentInfo class accordingly. If you have already done this, but you still experience problems, please send us your AppointmentInfo so we can examine it and check if it is alright.

Kind regards,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Scheduler
Asked by
Yang Qu
Top achievements
Rank 1
Answers by
Peter
Telerik team
Ilona
Top achievements
Rank 1
Share this question
or