I have a weird bug where I have defined DurationUnit on the SfGantt element, but it only works if the StartDate of the elements is not empty.
Markup for SfGrid element looks like this:
<SfGantt DataSource="@TaskCollection" DurationUnit="DurationUnit.Hour">
<GanttTaskFields Id="TaskId" Name="TaskName" Duration="Duration" Dependency="Dependency" StartDate="StartDate"/>
</SfGantt>
If I add data like this the DurationUnit is correctly set to be hours:
@code {
List<GanttDTO> TaskCollection = new List<GanttDTO>
{
new GanttDTO { TaskId = 1, TaskName = "Prufa 1", Duration = "12", StartDate = DateTime.Now },
new GanttDTO { TaskId = 2, TaskName = "Prufa 2", Duration = "24", Dependency = "1", StartDate = DateTime.Now },
new GanttDTO { TaskId = 3, TaskName = "Prufa 3", Duration = "48", Dependency = "2", StartDate = DateTime.Now },
new GanttDTO { TaskId = 4, TaskName = "Prufa 4", Duration = "16", Dependency = "2", StartDate = DateTime.Now }
};
}
But if I don't define the start date the DurationUnit is ignored and uses days:
@code {
List<GanttDTO> TaskCollection = new List<GanttDTO>
{
new GanttDTO { TaskId = 1, TaskName = "Prufa 1", Duration = "12" },
new GanttDTO { TaskId = 2, TaskName = "Prufa 2", Duration = "24", Dependency = "1" },
new GanttDTO { TaskId = 3, TaskName = "Prufa 3", Duration = "48", Dependency = "2" },
new GanttDTO { TaskId = 4, TaskName = "Prufa 4", Duration = "16", Dependency = "2" }
};
}
If i then try to set the DurationUnit with the duration attribute it works again:
@code {
List<GanttDTO> TaskCollection = new List<GanttDTO>
{
new GanttDTO { TaskId = 1, TaskName = "Prufa 1", Duration = "12hours" },
new GanttDTO { TaskId = 2, TaskName = "Prufa 2", Duration = "24hours", Dependency = "1" },
new GanttDTO { TaskId = 3, TaskName = "Prufa 3", Duration = "48hours", Dependency = "2" },
new GanttDTO { TaskId = 4, TaskName = "Prufa 4", Duration = "16hours", Dependency = "2" }
};
}