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

How can i add appointment resourcetypes resources dynamically ?

5 Answers 319 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
palak asked on 04 Jun 2011, 05:13 PM

I am using scheduleView. I need to create resourcetypes and resources in code behind means dynamically. How can i do that ? also after insert/update/remove resourcetypes/resources, how can i refresh scheduleview to take effect ?

kindly answer asap.

thank you


5 Answers, 1 is accepted

Sort by
Telerik team
answered on 06 Jun 2011, 08:02 AM
Hello Palak,

You can add/remove resource types to the ResourceTypeSource collection of RadScheduleView. In this case the scheduleview will refresh himself.
When you add/remove resources to the ResourceTypes you should also remove/add the resourceType to the
ResourceTypeSource. This will refresh the view again.


var resource1 = new Resource("Room1");
var resource2 = new Resource("Room2");
var resource3 = new Resource("Room3");

var resourceType = new ResourceType("Room");

var resourceTypes = new List<ResourceType>();
scheduleView.ResourceTypesSource = resourceTypes;

All the best,
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
Top achievements
Rank 1
answered on 07 Jun 2011, 09:50 AM

Thanks . actually i made custom RoomResources(resource) & RoomResourceTypes(resourcetype) class. below code not working.

In ScheduleView.Xaml.cs,

GradientStop gs1 = new GradientStop();
           gs1.Color = Color.FromArgb(255, 0, 255, 0);
           gs1.Offset = 0;
           GradientStop gs2 = new GradientStop();
           gs2.Color = Color.FromArgb(255, 0, 0, 255);
           gs2.Offset = 1;
           LinearGradientBrush resourceBrush = new LinearGradientBrush();
           resourceBrush.StartPoint = new Point(0.5, 0);
           resourceBrush.EndPoint = new Point(0.5, 1);
           //p.Fill = resourceBrush;
           RoomResources myResource = new RoomResources();
           myResource.Name = "Room One";
           myResource.Brush = resourceBrush;
           RoomResources myResourceTwo = new RoomResources();
           myResourceTwo.Name = "Room Two";
           myResourceTwo.Brush = resourceBrush;
           RoomResourceTypes myResourceType = new RoomResourceTypes();
           myResourceType.ResourceTypeName = "Rooms";
           List<RoomResourceTypes> resourceTypes = new List<RoomResourceTypes>();
           SchedulerView.ResourceTypesSource = resourceTypes;

in SchedulerView.Xaml
<telerik:RadScheduleView x:Name="SchedulerView" Grid.Column="0" Grid.Row="1"
                         TimeRulerItemStyleSelector="{StaticResource TimeRulerItemStyleSelector}"
                         GroupHeaderContentTemplateSelector="{StaticResource GroupHeaderContentTemplateSelector}"
            <telerik:ResourceGroupDescription ResourceType="Rooms" />
        <telerik:DayViewDefinition TimerulerMajorTickStringFormat="{}{0:%H}:{0:%m} "
        MajorTickLength="1d" MinTimeRulerExtent="3000" />
        <telerik:WeekViewDefinition MinorTickLength="1h" 
        TimerulerMajorTickStringFormat="{}{0:h tt}:{0:mm} "
        TimerulerMinorTickStringFormat=":{0:mm} "
        MinTimeRulerExtent="3000" />
        <telerik:MonthViewDefinition TimerulerGroupStringFormat="< {0:dddd} >" 
        GroupHeaderDateStringFormat="{}{0:MM/dd}" />
        <telerik:TimelineViewDefinition TimerulerGroupStringFormat="{}{0:dd.MM.yyyy}" 

Kindly check & reply what is the problem with this.
Also give me some extra inforation about below points.
1)What is actually needed to show resources in scheduleView , And what is needed to show resources in ScheduleView Edit Dialog Window ?
2) when we add resources , it shows in DropDown control in Edit Dialog Window, can i add another type of control like textbox, checkbox etc.

thanks & regards
Top achievements
Rank 1
answered on 07 Jun 2011, 01:22 PM
You will have to get EditAppointmentDialogStyle source code from RadScheduleView template using Expression Blend and edit its EditAppointmentTemplate to add control like TextBox, CheckBox or ComobBox.  Here I added combobox in Appointment Dialog box
Top achievements
Rank 1
answered on 08 Jun 2011, 09:09 AM
thnx satyendra,

actually i am using vs 2010 not blend , so can't do on that way. yes i know abt ediappointmentdialogstyle, i used it when i needed custom properties in edit appointment dialog.

see, my problem is , i am assigning appointments dynamically to scheduleview, also i am creating resourcetypes/resources dynamically. Now i want to know how can i assign specific resource to particular resourcetype of scheduleview in code-behind.

check below.

ResourceAppointment newAppointment = e.Appointment as ResourceAppointment;
           listItem["Title"] = newAppointment.Subject.ToString();
           listItem["EventDate"] = Convert.ToDateTime(newAppointment.Start).ToLocalTime();
           listItem["EndDate"] = Convert.ToDateTime(newAppointment.End).ToLocalTime();
           listItem["Description"] = newAppointment.Body.ToString();
          //here i want to assign selected resource from dropdown to listitem but don't know how ?
            listItem["Rooms"] = ??
           listItem["Resources"] = ??

please suggest or show how to do CRUD operations when resources/resourcetypes dynamically added.

thanks & regards
Top achievements
Rank 1
answered on 09 Jun 2011, 08:39 AM
have you got anything regarding my problem ?
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Top achievements
Rank 1
Top achievements
Rank 1
Share this question