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.
7 Answers, 1 is accepted
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
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.
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
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.
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
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.
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