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

Grouping Appointments programmatically

4 Answers 275 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
LE DREAU Steeve
Top achievements
Rank 1
LE DREAU Steeve asked on 05 May 2011, 02:02 PM
Hi,

I have a problem using radScheduleView programmatically. Let me explain the situation :
I have some appointments that I would like to separate using resources and ResourceTypesSource property.
When creating them into XAML code, it works like a charm. but when trying to create them in code behind, it doesn't work, all my appointments are blended.

Here is an example using XAML :

<telerik:RadScheduleView x:Name="Sched"
                                 AppointmentsSource="{Binding Appointments}"
                                 GroupHeaderContentTemplateSelector="{StaticResource GroupHeaderTplSelector}">
             
            <telerik:RadScheduleView.ViewDefinitions>
                <telerik:TimelineViewDefinition />
            </telerik:RadScheduleView.ViewDefinitions>
             
            <telerik:RadScheduleView.ResourceTypesSource>
                <telerik:ResourceTypeCollection>
                    <telerik:ResourceType Name="Location">
                        <telerik:Resource ResourceName="Loc 1" />
                        <telerik:Resource ResourceName="Loc 2" />
                        <telerik:Resource ResourceName="Loc 3" />
                    </telerik:ResourceType>
                </telerik:ResourceTypeCollection>
            </telerik:RadScheduleView.ResourceTypesSource>
             
            <telerik:RadScheduleView.GroupDescriptionsSource>
                <telerik:GroupDescriptionCollection>
                    <telerik:ResourceGroupDescription ResourceType="Location">
 
                    </telerik:ResourceGroupDescription>
                </telerik:GroupDescriptionCollection>
            </telerik:RadScheduleView.GroupDescriptionsSource>
             
        </telerik:RadScheduleView>

And here is the code that generate appointments :

Dim r1 As New Resource("Loc 1", "Location")
Dim r2 As New Resource("Loc 2", "Location")
Dim r3 As New Resource("Loc 3", "Location")
 
 Me.Appointments = New ObservableCollection(Of Appointment)
 
        For i As Integer = 0 To 8
            Me.Appointments.Add(GenererApp(r1))
        Next
 
        For i As Integer = 0 To 8
            Me.Appointments.Add(GenererApp(r2))
        Next
 
        For i As Integer = 0 To 8
            Me.Appointments.Add(GenererApp(r3))
        Next

Here is the code for GenererApp :

Private Function GenererApp(r As Resource) As Appointment
        Dim a As New Appointment() With {.Start = DateTime.Now, .End = DateTime.Now.AddDays(1)}
        a.Resources.Add(r)
        a.Subject = "coucou"
        Me.Appointments.Add(a)
        Return a
    End Function

Now, here is the programmatically method that doesn't work :

<telerik:RadScheduleView x:Name="Sched"
                                 AppointmentsSource="{Binding Appointments}"
                                 GroupHeaderContentTemplateSelector="{StaticResource GroupHeaderTplSelector}">
             
            <telerik:RadScheduleView.ViewDefinitions>
                <telerik:TimelineViewDefinition />
            </telerik:RadScheduleView.ViewDefinitions>
             
            <telerik:RadScheduleView.GroupDescriptionsSource>
                <telerik:GroupDescriptionCollection>
                    <telerik:ResourceGroupDescription ResourceType="Location">
 
                    </telerik:ResourceGroupDescription>
                </telerik:GroupDescriptionCollection>
            </telerik:RadScheduleView.GroupDescriptionsSource>
             
        </telerik:RadScheduleView>

In the code behind :

'Resources
       Dim rc As New ResourceTypeCollection
       Dim rt As New ResourceType("Location")
       rc.Add(rt)
 
       Dim r1 As New Resource("Loc 1", "Location")
       Dim r2 As New Resource("Loc 2", "Location")
       Dim r3 As New Resource("Loc 3", "Location")
 
       Me.Sched.ResourceTypesSource = rc
 
       'Appointments
       Me.Appointments = New ObservableCollection(Of Appointment)
 
       For i As Integer = 0 To 8
           Me.Appointments.Add(GenererApp(r1))
       Next
 
       For i As Integer = 0 To 8
           Me.Appointments.Add(GenererApp(r2))
       Next
 
       For i As Integer = 0 To 8
           Me.Appointments.Add(GenererApp(r3))
       Next

With this one, my appointments are displayed but not grouped...
Did I forgot something ?
Thanks

Steeve

4 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 06 May 2011, 02:51 PM
Hello ,

I suggest you edit the following code :

Dim rc As New ResourceTypeCollection
Dim rt As New ResourceType("Location")
rc.Add(rt)
Dim r1 As New Resource("Loc 1", "Location")
Dim r2 As New Resource("Loc 2", "Location")
Dim r3 As New Resource("Loc 3", "Location")
Me.Sched.ResourceTypesSource = rc

like it is shown below:

Dim rc As New ResourceTypeCollection
Dim rt As New ResourceType("Location")
rc.Add(rt)
Dim r1 As New Resource("Loc 1")
Dim r2 As New Resource("Loc 2")
Dim r3 As New Resource("Loc 3")

rt.Resources.Add(r1)

rt.Resources.Add(r2)

rt.Resources.Add(r3)
Me.Sched.ResourceTypesSource = rc

Regards,
Rosi
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
LE DREAU Steeve
Top achievements
Rank 1
answered on 06 May 2011, 04:19 PM
Hi,

Thanks for your answer, it works !

Regards

Steeve
0
LE DREAU Steeve
Top achievements
Rank 1
answered on 09 May 2011, 08:08 AM
Hi,

Is there a way to debug why grouping doesn't work ? Because I've tried to make grouping in a simple project, it works. But when trying this into our complex project no group appears and I don't know why....

Thanks

Steeve
0
George
Telerik team
answered on 11 May 2011, 06:28 PM
Hello,

 
Please, double check that your ResourceGroupDescription.ResourceType and the ResourceType names matches. Also, please refer to our online example of the RadScheduleView grouping - http://demos.telerik.com/silverlight/#ScheduleView/Grouping/Basics

I hope this helps. If it doesn't, could you please give us more information about how the RadScheduleView grouping is performed? I am glad to assist you further.

Best wishes,
George
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
LE DREAU Steeve
Top achievements
Rank 1
Answers by
Rosi
Telerik team
LE DREAU Steeve
Top achievements
Rank 1
George
Telerik team
Share this question
or