Resources with custom schedules
Your resource objects could contain information about their custom schedules that can be bound to the gantt. This information should eventually be converted to a WorkTimeSchedule instance.
a)
There are some built-in utilities that can convert a string representation of this custom schedule (in a predefined format) into a WorkTimeSchedule instance.
So, for example, if your resources are defined as follows:
|
In HTML |
|
$('#container').GanttControl({ .... .... ResourceItemsSource: new Array({ ResourceID: 1, ResourceName: "Resource 1" }, { ResourceID: 2, ResourceName: "Resource 2", CustomScheduleString: "Mon 8:00:00 16:00:00;Tue 8:00:00 16:00:00;Wed 8:00:00 16:00:00" }), ResourceIDBinding: new RadiantQ.BindingOptions("ResourceID"), ResourceNameBinding: new RadiantQ.BindingOptions("ResourceName"), // Then you can setup this binding in the GanttControl: ResourceScheduleBinding: { Property: "CustomScheduleString", Converter: RadiantQ.Gantt.StringToWorkTimeScheduleConverter } }); |
|
In ASP.NET MVC |
|
<%= Html.JQProjectGantt( new JQProjectGanttSettings() { ControlId = "gantt_container", Options = new ProjectGanttOptions() { ResourceItemsSource = new List<ResourceInfo>() { new ResourceInfo() { ResourceID = 1, ResourceName = "Resource 1" }, new ResourceInfo() { ResourceID = 2, ResourceName = "Resource 2", CustomScheduleString = "Mon 8:00:00 16:00:00;Tue 8:00:00 16:00:00;Wed 8:00:00 16:00:00" } }, ResourceIDBinding= new Binding("ResourceID"), ResourceNameBinding= new Binding("ResourceName"), // Then you can setup this binding in the GanttControl: ResourceScheduleBinding = new Binding("CustomScheduleString", "RadiantQ.Gantt.StringToWorkTimeScheduleConverter") } })%> |
The gantt will then use this custom schedule for the resources.
|
In ASP.NET |
|
<script runat="server"> protected void gantt_Load(object sender, EventArgs e) { this.gantt.ResourceItemsSource = new List<ASPNetGanttDemo.DataSources.ResourceInfo>() { new ASPNetGanttDemo.DataSources.ResourceInfo(){ ResourceID = 1, ResourceName = "Resource 1" }, new ASPNetGanttDemo.DataSources.ResourceInfo(){ ResourceID = 2, ResourceName = "Resource 2", CustomScheduleString = "Mon 8:00:00 16:00:00;Tue 8:00:00 16:00:00;Wed 8:00:00 16:00:00" }, new ASPNetGanttDemo.DataSources.ResourceInfo(){ ResourceID = 3, ResourceName = "Resource 3" } }; } </script> <RQ:GanttControl ID="gantt" DataSourceUrl="../../DataSources/TaskListHandler.ashx" runat="server" > <ResourceIDBinding Property="ResourceID" /> <ResourceNameBinding Property="ResourceName" /> <ResourceScheduleBinding Property="CustomScheduleString" Converter="RadiantQ.Gantt.StringToWorkTimeScheduleConverter" /> </RQ:GanttControl> |
The gantt will then use this custom schedule for the resources.
b)
Alternatively if you have a property that exposes a WorkTimeSchedule instance, that can be directly be bound to the gantt as follows:
|
{ ResourceID: 2, ResourceName: "Resource 2", CustomSchedule: new RadiantQ.Gantt.WorkTimeSchedule("Custom Schedule", CustomScheduleForRes2) } |
|
In HTML |
|
function CustomScheduleForRes2(date) { // You can choose to take into account holidays here. // For better performance cache the intervals for dates instead of creating a new collection every time. if ((date.getDayName() != "Saturday") && (date.getDayName() != "Sunday") && (date.getDayName() != "Friday")) { var intervals = new RadiantQ.Gantt.TimePeriodCollection(); intervals.Add(new RadiantQ.Gantt.TimePeriod(date.clone().addHours(8.0), null, new RQTimeSpan(0, 8, 0, 0, 0))); return intervals; } else { return null; } } |
|
In HTML |
|
$('#container').GanttControl({ .... .... ResourceScheduleBinding: new RadiantQ.BindingOptions("CustomSchedule") }); |
|
In ASP.NET MVC |
|
<script type="text/javascript">
function CustomScheduleForRes2(date) { // You can choose to take into account holidays here. // For better performance cache the intervals for dates instead of creating a new collection every time. if ((date.getDayName() != "Saturday") && (date.getDayName() != "Sunday") && (date.getDayName() != "Friday")) { var intervals = new RadiantQ.Gantt.TimePeriodCollection(); intervals.Add(new RadiantQ.Gantt.TimePeriod(date.clone().addHours(8.0), null, new RQTimeSpan(0, 8, 0, 0, 0))); return intervals; } else { return null; } } Object.defineProperty(window, "CustomSchedule", { get: function () { return new RadiantQ.Gantt.WorkTimeSchedule("Custom Schedule", CustomScheduleForRes2) }, set: function (value) { }, enumerable: true, configurable: true });
</script> |
|
In ASP.NET MVC |
|
<%= Html.JQProjectGantt( new JQProjectGanttSettings() { ControlId = "gantt_container", AfterGanttWidgetInitializedCallback = "AfterGanttWidgetInitializedCallback", DataSourceUrl = new Uri("/Home/GetProjectGanttItemsource", UriKind.RelativeOrAbsolute), Options = new ProjectGanttOptions() { ResourceItemsSource = new List<FlexyGanttMVCSample.Controllers.ResourceInfo>() { new FlexyGanttMVCSample.Controllers.ResourceInfo() { ResourceID = 1, ResourceName = "Resource 1", CustomSchedule = "CustomSchedule" }, new FlexyGanttMVCSample.Controllers.ResourceInfo() { ResourceID = 3, ResourceName = "Resource 3" }, new FlexyGanttMVCSample.Controllers.ResourceInfo() { ResourceID = 2, ResourceName = "Resource 2" } }, ResourceIDBinding = new Binding("ResourceID"), ResourceNameBinding = new Binding("ResourceName"), ResourceScheduleBinding = new Binding("CustomSchedule"), } })%> |
|
In ASP.NET |
|
<script type="text/javascript">
function CustomScheduleForRes2(date) { // You can choose to take into account holidays here. // For better performance cache the intervals for dates instead of creating a new collection every time. if ((date.getDayName() != "Saturday") && (date.getDayName() != "Sunday") && (date.getDayName() != "Friday")) { var intervals = new RadiantQ.Gantt.TimePeriodCollection(); intervals.Add(new RadiantQ.Gantt.TimePeriod(date.clone().addHours(8.0), null, new RQTimeSpan(0, 8, 0, 0, 0))); return intervals; } else { return null; } } Object.defineProperty(window, "CustomSchedule", { get: function () { return new RadiantQ.Gantt.WorkTimeSchedule("Custom Schedule", CustomScheduleForRes2) }, set: function (value) { }, enumerable: true, configurable: true });
</script> |
|
In ASP.NET |
|
<script runat="server"> protected void gantt_Load(object sender, EventArgs e) { this.gantt.ResourceItemsSource = new List<ASPNetGanttDemo.DataSources.ResourceInfo>() { new ASPNetGanttDemo.DataSources.ResourceInfo(){ ResourceID = 1, ResourceName = "Resource 1" }, new ASPNetGanttDemo.DataSources.ResourceInfo(){ ResourceID = 2, ResourceName = "Resource 2", CustomSchedule = "CustomSchedule"}, new ASPNetGanttDemo.DataSources.ResourceInfo(){ ResourceID = 3, ResourceName = "Resource 3" } }; } </script> <RQ:GanttControl ID="gantt" DataSourceUrl="../../DataSources/TaskListHandler.ashx" runat="server" > <ResourceIDBinding Property="ResourceID" /> <ResourceNameBinding Property="ResourceName" /> <ResourceScheduleBinding Property="CustomSchedule" /> </RQ:GanttControl> |
This is illustrated in this samples:
In HTML : ..\Samples\GanttControlSkeletonWithResources.htm.
In ASP.NET MVC : ..\Views\Home\ProjectGantt\GanttControlSkeletonWithResources.cshtml.
In ASP.NET : ..\Samples\ProjectGantt\GanttControlSkeletonWithResources.aspx.
� RadiantQ 2022. All Rights Reserved.