Group Header in code behind

7 posts, 0 answers
  1. Marcus
    Marcus avatar
    35 posts
    Member since:
    Aug 2012

    Posted 02 Apr 2013 Link to this post

    Hello.

    I have a problem creating group-headers for a RadScheduleView from code behind.
    I want to have multiple header in a timeline-view, one for each selected user. I use custom appointments, which have the UserID within.

    My code looks like this at the moment:
    ResourceTypeCollection Group = new ResourceTypeCollection();
    ResourceType User = new ResourceType("User");
     
    for (int i = 0; i < UserGroup.UserIDs.Count; i++)
    {
     
            Resource Person = new Resource();
            Person.ResourceName = UserGroup.UserIDs[i];               
            Person.DisplayName = UserGroup.UserName[i];
            User.Resources.Add(Person);
         
    }
     
    Group.Add(User);
    ScheduleView.ResourceTypesSource = Group;

    But when displayed, there appears not a single header.
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 05 Apr 2013 Link to this post

    Hello Marcus,

    Thank you for contacting us.

    Have you set the GroupDescriptionsSource property of the ScheduleView - it is needed to enable the grouping? You can check here for more details.

    Regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Marcus
    Marcus avatar
    35 posts
    Member since:
    Aug 2012

    Posted 05 Apr 2013 Link to this post

    Well, okay, Headers are shown now.

    But not a single appointment appears...
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 08 Apr 2013 Link to this post

    Hi Marcus,

    When RadScheduleView is grouped by ResourceType, only the appointments that have Resource assigned are shown. To display all the appointments, you should set ShowNullGroup property of the ResourceGroupDescription like this:

    <telerik:RadScheduleView.GroupDescriptionsSource>
        <telerik:GroupDescriptionCollection>
            <telerik:ResourceGroupDescription ResourceType="User" ShowNullGroup="True" />
            <telerik:DateGroupDescription />
        </telerik:GroupDescriptionCollection>
    </telerik:RadScheduleView.GroupDescriptionsSource>

    Hope it is ok now.

    Regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Marcus
    Marcus avatar
    35 posts
    Member since:
    Aug 2012

    Posted 09 Apr 2013 Link to this post

    Thanks for help Yana. Appointments are shown now, but that was not exactly what I want.

    I want the appointments to be shown in the correct groupheader. One Header for each user in the group.

    Resource User = new Resource();
    User.ResourceName = UserGroup.UserIDs[i];              
    User.DisplayName = UserGroup.UserName[i];


    And this appointment:
    public class customAppointment : Appointment
    {
     
               [...]
           

            private string userID;
            public string UserID { get {return userID;} set {userID = value;} }
     
    }


    I want to assign the UserID-property in the appointment to the list 'UserGroup.UserIDs'. An appointment belonging to the user with ID = '0001' for example, should be shown in the groupheader name: '0001', which is displayed as 'UserGroup.UserName'.

    At this moment, all appointments are shown in the nullgroup. No appointment is shown in 'his' correct groupheader.
  7. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 09 Apr 2013 Link to this post

    Hello Marcus,

    The appointments will be shown in the correct resource group only if this resource is added to the Resources collection of each appointment.  Note that RadScheduleView cannot connect the custom property of the appointment to the corresponding resource automatically.

    So when creating appointments, you should add the following:

    app.Resources.Add(User.Resources.Where(p => p.ResourceName == app.UserID).First());

    In other words, find the resource whose ResourceName is the same as UserID and assign it to the appointment.

    I hope this helps.

    Greetings,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. Marcus
    Marcus avatar
    35 posts
    Member since:
    Aug 2012

    Posted 09 Apr 2013 Link to this post

    Thank you. Everything works fine now.
Back to Top
UI for WPF is Visual Studio 2017 Ready