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

Add appointment with code

3 Answers 188 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Vanja
Top achievements
Rank 1
Vanja asked on 02 Jun 2011, 07:16 AM
Hello,

Can you please post example or tell me how to add new appointment from code in ScheduleView.. I want to load all appointments from XML, parse it and then bind into ScheduleView.. 

Thank you

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 02 Jun 2011, 07:59 AM
Hi Vanja,

Please check this help article - it demonstrates how to load appointments in the RadScheduleView using MVVM approach. You can add your logic for parsing the XML file without a problem.

Hope this helps.

Greetings,
Yana
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
Vanja
Top achievements
Rank 1
answered on 02 Jun 2011, 09:44 AM
Can you please help me with adding appointment from code.. This is my code in C#.. I have" ObservableCollection<ResourceType> ResourcesTypes" as ScheduleView groups so I want to add appointments in that groups with "ObservableCollection<Appointment> Appointments"..

Here is my code...

Groups:
 
private ObservableCollection<ResourceType> GenerateResourceTypes()
     {
         ObservableCollection<ResourceType> result = new ObservableCollection<ResourceType>();
         ParseXML();
   
         ResourceType kanal = new ResourceType("Kanal");
         for (int i = 0; i < KanalList.Count; i++)
         {
             Resource imekanala = new Resource(KanalList[i]);
             kanal.Resources.Add(imekanala);
 
         }
          
         result.Add(kanal);
         return result;
     }
 
     public MyViewModel()
     {
         ResourcesTypes = GenerateResourceTypes();
         Appointments = new ObservableCollection<Appointment>();          
     }

I tried to add appointment in group like this but its not working..

public ObservableCollection<Appointment> Appointments { get; set; }
   public ObservableCollection<ResourceType> ResourcesTypes { get; set; }
 
   private ObservableCollection<ResourceType> GenerateResourceTypes()
   {
       ObservableCollection<ResourceType> result = new ObservableCollection<ResourceType>();
       ParseXML();
 
       Appointment test = new Appointment { Start = DateTime.Now, End = DateTime.Today.AddHours(2), Subject = "Appointment" };
 
       ResourceType kanal = new ResourceType("Kanal");
       for (int i = 0; i < KanalList.Count; i++)
       {
           Resource imekanala = new Resource(KanalList[i]);
           kanal.Resources.Add(imekanala);
       }
       result.Add(kanal);
       return result;
   }
 
   public MyViewModel()
   {
       ResourcesTypes = GenerateResourceTypes();
       Appointments = new ObservableCollection<Appointment>();          
   }

Don't know how to add appointment in ResourcesTypes ??
0
Accepted
Yana
Telerik team
answered on 03 Jun 2011, 09:26 AM
Hello Vanja,

You just need to add the resource to Resources property of the appointment:

Appointment test = new Appointment {
   Start = DateTime.Now,
    End = DateTime.Today.AddHours(2),
    Subject =
"Appointment"
};
test.Resources.Add(new Resource("Kanal1", "Kanal"));

Also note the you should group the RadScheduleView by "Kanal" resource type in order to display the appointment:

<telerik:RadScheduleView x:Name="ScheduleView"
            AppointmentsSource="{Binding Appointments}"
                ResourcesSource="{Binding ResourcesTypes}">
    <telerik:RadScheduleView.ViewDefinitions>
        <telerik:MonthViewDefinition />
        <telerik:WeekViewDefinition />
    </telerik:RadScheduleView.ViewDefinitions>
    <telerik:RadScheduleView.GroupDescriptionsSource>
        <telerik:GroupDescriptionCollection>
            <telerik:DateGroupDescription />
            <telerik:ResourceGroupDescription ResourceType="Kanal" />
        </telerik:GroupDescriptionCollection>
    </telerik:RadScheduleView.GroupDescriptionsSource>
</telerik:RadScheduleView>

Hope this helps.

All the best,
Yana
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
ScheduleView
Asked by
Vanja
Top achievements
Rank 1
Answers by
Yana
Telerik team
Vanja
Top achievements
Rank 1
Share this question
or