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
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.
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?
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
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.
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