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

Combination of Slot and ResourceType is not working

5 Answers 98 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Björn
Top achievements
Rank 1
Björn asked on 08 Feb 2012, 07:15 AM
For planning courses where I have to assign teachers, I will use the RadSchedulerView,
where the calendar from the course and teachers are visible. The calendar of the teachers must be read only!
So I tried to integrate readonly slot for the teachers resources.

Implementation
I've defined a ResourceType 'Calendar' with the Resources 'Course', 'Teacher1' and 'Teacher2'. Added different appointments:
  • 'Course1' => for resource 'Course', 'Teacher1' (the teacher is booked for the course)
  • 'Course2' => for resource 'Course'
  • 'Private Appoinment' => for resource 'Teacher2' (so during that time, he cannot be booked for the course)

All this is grouped in the RadSchedulerView with DataGroupDescription, ResourceGroupDescription ResourceType="Calendar". That looks very good.
Now I want to make the Resources for 'Teacher1' and 'Teacher2' as readonly. So I defined a readonly slot as proposed in the telerik demos.
But with no success.

To find the problem,I stripped down the code to find the cause - but with no success.
Finally I started with the sample code from Style a read-only slot :
- And added following code in the ctor of the MyViewModel after defining the slot:
ResourcesTypes = new ObservableCollection<ResourceType>();
var resourceTypeCalendar = new ResourceType("Calendar");
ResourcesTypes.Add(resourceTypeCalendar);
 
// calendar for course appointments
var resourceCourse = new Resource("Course");
resourceTypeCalendar.Resources.Add(resourceCourse);
 
// calendar for course appointments
var resourceTeacher1 = new Resource("Teacher1");
resourceTypeCalendar.Resources.Add(resourceTeacher1);
 
// calendar for course appointments
var resourceTeacher2 = new Resource("Teacher1");
resourceTypeCalendar.Resources.Add(resourceTeacher2);
 
var today = DateTime.Today;
var appointment = new Appointment();
appointment.UniqueId = Guid.NewGuid().ToString();
appointment.Subject = "Course1";
appointment.Start = today.AddHours(9);
appointment.End = appointment.Start.AddHours(2);
// appointment from course & teacher2
appointment.Resources.Add(resourceCourse);
appointment.Resources.Add(resourceTeacher1);
Appointments.Add(appointment);
 
appointment = new Appointment();
appointment.UniqueId = Guid.NewGuid().ToString();
appointment.Subject = "Course2";
appointment.Start = today.AddDays(2).AddHours(8);
appointment.End = appointment.Start.AddHours(4);
// appointment from course
appointment.Resources.Add(resourceCourse);
Appointments.Add(appointment);
 
appointment = new Appointment();
appointment.UniqueId = Guid.NewGuid().ToString();
appointment.Subject = "Private Appoinment";
appointment.Start = today.AddDays(2).AddHours(7);
appointment.End = appointment.Start.AddHours(8);
// appointment from teacher2
appointment.Resources.Add(resourceTeacher2);
Appointments.Add(appointment);

- defined the property: public ObservableCollection<ResourceType> ResourceTypes { set; get; }
- and added in the MainPage.xaml following:
<telerik:RadScheduleView
            AppointmentsSource="{Binding Appointments}"
            ResourceTypesSource="{Binding ResourcesTypes}"
            SpecialSlotsSource="{Binding SpecialSlots}" SpecialSlotStyleSelector="{StaticResource SpecialSlotStyleSelector}">
    <telerik:RadScheduleView.ViewDefinitions>
        <telerik:WeekViewDefinition />
    </telerik:RadScheduleView.ViewDefinitions>
    <telerik:RadScheduleView.GroupDescriptionsSource>
        <telerik:GroupDescriptionCollection>
            <telerik:DateGroupDescription />
            <telerik:ResourceGroupDescription ResourceType="Calendar" />
        </telerik:GroupDescriptionCollection>
    </telerik:RadScheduleView.GroupDescriptionsSource>
</telerik:RadScheduleView>

When I run that, it will show the three resources grouped, but the defined slot is not showing!
If I remove the line 'ResourceTypesSource="{Binding ResourcesTypes}"', it will show the slot but no more the three resources!

What's wrong?
How can I define a readonly slot for the resource 'Teacher1' and 'Teacher2'?
Idea: assign the teacher resources to the readOnlyslot (readOnlyslot.Resources.Add(resourceTeacher1); ).
Can you post a sample for that?

Regards
Björn.



5 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 15 Feb 2012, 04:09 PM
Hello Björn,

Since you already have stripped your project, could you please send it to us in order to run it here locally and debug it. In that way we will be able to provide you with solution in a timely manner.

Looking forward to your reply.

Regards,
Konstantina
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Björn
Top achievements
Rank 1
answered on 15 Feb 2012, 04:41 PM
Hello Konstantina

You find my project in my dropbox. When you run it, it will show the special slots as the sample.
I've marked my changes with 'ADDED CODE by bbee' in MyViewModel.cs and MainPage.xaml.

When you change the part in MainPage.xaml: add the ResourceTypesSource="{Binding ResourcesTypes}".
It should display all three resource columns in combination with the special slots.

If you solve the problem, can you send me a sample project with my requirement:
- define readonly slot for the resource 'Teacher1' and 'Teacher2'
See for that also the attached screen.

Thanks
Björn.
0
Konstantina
Telerik team
answered on 17 Feb 2012, 03:41 PM
Hello Björn,

There are a few important things that you have missed:
- there should be defined Copy() and CopyFrom() methods for the Slots
- a resource should be assign to the Slots and also the IsReadOnly property set to True, if you want do disable the editing on these slots
- the RecurrenceRulePattern in this case should be made weekly, since there are the WeekDays which repeat.
Attached I am sending you the sample project with these corrections made. I have commented out the other slots  in order to isolate the problem, but since one type is already defined correctly, you will be able to apply it to the others.

Hope this helps.

All the best,
Konstantina
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Björn
Top achievements
Rank 1
answered on 24 Feb 2012, 07:42 AM
Hi Konstantina

It's still not clear.
Can you send me a runnable sample where you define a Readonly-Slot which is assigned to the resources 'Teacher1' & 'Teacher2' but not resource 'Course'.
No other slots are required.

Thanks
Björn.
0
Accepted
Yana
Telerik team
answered on 28 Feb 2012, 03:44 PM
Hi Björn,

I've modified the project to make the use of the SpecialSlots more clear. 

Please note that in your case you're assigning one appointment "Course 1" to "Course" and "Teacher1" resources, so it is placed in a readonly and regular slots at the same time - that's why you will be able to edit it.

Hope this helps.


Kind regards,
Yana
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
ScheduleView
Asked by
Björn
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Björn
Top achievements
Rank 1
Yana
Telerik team
Share this question
or