Timeline - Appointment relative position when Grouping by resource

8 posts, 0 answers
  1. Viet
    Viet avatar
    5 posts
    Member since:
    Oct 2015

    Posted 29 Oct 2015 Link to this post

    I am working on the timeline of the Schedule control of UI for WinForms. My purpose is to show maximum number of resources and all of their appointments so that we do not need to scroll to see appointments of a resource.
    In order to do that, I must have the information like shown in the screen shot attached. That is the number of appointment line inside each resource. Do we have this information somewhere inside the control? Or I must calculate it myself. What information can I base on in order to calculate that in both of the case radScheduler1.EnableExactTimeRendering is true or false?.

    Do we have a method that can get the relative position of an AppointmentElement inside a resource in case grouping by resource?

    Thanks.

  2. Hristo
    Admin
    Hristo avatar
    716 posts

    Posted 02 Nov 2015 Link to this post

    Hi Viet,

    Thank you for writing.

    The sizes of the resources are defined by their number and the available size in the view. RadScheduler provides an API for adjusting their sizes, however, please note that these calculations are relative. The responsible method is SetResourceSize and it requires a parameter as a proportion determining what part of the view will be occupied by the selected resource.

    The following documentation article provides additional information: Grouping by Resources. I am also attaching a demo project and a gif file showing how RadScheduler looked on my end.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Viet
    Viet avatar
    5 posts
    Member since:
    Oct 2015

    Posted 04 Nov 2015 Link to this post

    Hi Hristo,

    I am afraid this hasn't answered my question. I would like to have a way to know the number of lines of appointments that need to be displayed in the timeline view of each resource. With this information, I can adjust the height of each resource accordingly so that my user doesn't need to scroll to be able to see all of a resource's appointments.

    I had described this on the screenshot attached in the beginning of the post. Please have a look.

    Thanks.

  5. Hristo
    Admin
    Hristo avatar
    716 posts

    Posted 05 Nov 2015 Link to this post

    Hello Viet,

    Thank you for writing.

    The project I last sent you includes an example how you can extract a resource from a cell. Then knowing the resource you can find the unique appointments associated to it: 
    IResource cellResource = this.radScheduler1.SelectionBehavior.CurrentCellElement.View.GetResource();
    List<IEvent> appointments = this.radScheduler1.Appointments.Where(a => a.ResourceId == cellResource.Id).ToList();

    Then, knowing their count you can perform further calculations and adjust the resource size as shown in the previously attached project.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  6. Viet
    Viet avatar
    5 posts
    Member since:
    Oct 2015

    Posted 06 Nov 2015 Link to this post

    Hi Hristo,

    My question is how I can calculate the size needed for each resource from the list of appointments so that I can adjust it?

    As you can see, in the timeline, the control automatically align overlapped appointments into appointment lines.

    Thanks.

  7. Hristo
    Admin
    Hristo avatar
    716 posts

    Posted 09 Nov 2015 Link to this post

    Hello Viet,

    Thank you for writing back.

    You can get the maximums of all the scroll bars of the resources and then knowing the ratio between the different groups you can adjust a particular resource or all of them. Please check my snippet below:
    List<int> scrollMax;
    private void radScheduler1_ActiveViewChanged(object sender, SchedulerViewChangedEventArgs e)
    {
        if (e.NewView is SchedulerTimelineView)
        {
            TimelineGroupingByResourcesElement groupedTimelineViewElement = this.radScheduler1.SchedulerElement.ViewElement as TimelineGroupingByResourcesElement;
            if (groupedTimelineViewElement != null)
            {
                IList<SchedulerTimelineViewElement> childViewElements = groupedTimelineViewElement.GetChildViewElements();
                this.scrollMax = new List<int>();
                for (int i = 0; i < childViewElements.Count; i++)
                {
                    this.scrollMax.Add(childViewElements[i].VScrollBar.Maximum);
                }
            }
        }
    }

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  8. Viet
    Viet avatar
    5 posts
    Member since:
    Oct 2015

    Posted 09 Nov 2015 in reply to Hristo Link to this post

    Hi Hristo,

    I have tried your code snippet, but it seems not fit my need. Please have a look at the attached screen shot with my note in red inside.

    I need a way to calculate the height of resouces that fit the needs of space to draw resources without having to scroll. Ofcource, if n resources are displayed, then we can adjust resource No.2 - No.n according to the resource No.1. I need a way to calculate the needed height of all of n resources so that I can display a number of resources that fit the screen height when user scroll the scheduler control.

    Thanks.

  9. Hristo
    Admin
    Hristo avatar
    716 posts

    Posted 10 Nov 2015 Link to this post

    Hi Viet,

    Thank you for writing back.

    I am not sure why the maximum value of the vertical scrollbar returns 100, it appears that it has remained with its default value. Now I am attaching my sample project as well as a gif file showing how the scheduler behaved on my end.

    In case you are still experiencing issues please open up a support ticket referring this forum thread and attach your project so that I can test it locally.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready