BoldDesk®Customer service software with ticketing, live chat & omnichannel support, starting at $99/mo for unlimited agents. Try for free!
Hello, I have a question concerning a feature I have to develop with one of the syncfusion control.
The problem is that I don't know what control is the most suitable.
Can you help me to find the right control to use ?
Business class looks like :
public class Activity
{
public int Id { get; set; }
public string Name { get; set; }
public decimal TotalDistance { get; set; }
public List<ActivityRange> Ranges { get; set; }
}
public class ActivityRange
{
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public TimeSpan TotalTime { get { return EndDate - StartDate; } }
public int StatusActivity { get; set; }
public SolidColorBrush StatusColor { get; set; }
}
--> The Activity Range represents some range per day, a color is associate with the range (I can use a converter to put the color with a particular status).
Here is a screenshot of what it should look like :
Thank you very much for the support.
Best Regards,
Nicolas
<Style x:Key="TaskNode" TargetType="{x:Type gchart:GanttNode}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type gchart:GanttNode}">
<Border Name="PART_Border"
Height="22"
VerticalAlignment="Center"
BorderThickness="1"
ClipToBounds="True"
Opacity="0.8"
Background="{Binding StatusColor}">
<Grid>
....
<ToolTipService.ToolTip> <ToolTip Content="{TemplateBinding DataContext}"
ContentTemplate="{TemplateBinding ToolTipTemplate}" />
</ToolTipService.ToolTip>
<Thumb x:Name="PART_DragDropThumb"
....
</Thumb>
<Thumb x:Name="PART_LeftThumb"
....
/>
</Thumb.Template>
</Thumb>
<Thumb x:Name="PART_RightThumb">
...
</Thumb.Template> </Thumb>
...
</Style>
.... <gantt:GanttControl x:Name="Gantt" Loaded="Gantt_Loaded" ....
<gantt:GanttControl.Resources>
<Style BasedOn="{StaticResource TaskNode}"
TargetType="gchart:GanttNode" />
</gantt:GanttControl.Resources>
</gantt:GanttControl> |
private void Gantt_Loaded(object sender, RoutedEventArgs e)
{
Gantt.GanttGrid.Loaded += GanttGrid_Loaded;
}
private void GanttGrid_Loaded(object sender, RoutedEventArgs e)
{
for(int i=0;i<Gantt.GanttGrid.Columns.Count; i++)
{
if(Gantt.GanttGrid.Columns[i].HeaderText == "Start"|| Gantt.GanttGrid.Columns[i].HeaderText == "Finish")
{
Gantt.GanttGrid.Columns.RemoveAt(i);
i--;
}
else if(Gantt.GanttGrid.Columns[i].HeaderText == "Task Name")
{
Gantt.GanttGrid.Columns[i].HeaderText = "Activity";
}
else if (Gantt.GanttGrid.Columns[i].HeaderText =="Duration")
{
Gantt.GanttGrid.Columns[i].HeaderText = "Tots.";
}
}
GridTreeColumn column = new GridTreeColumn
{
MappingName = "TotalDistance",
HeaderText = "Distance",
Width = 100,
StyleInfo=new GridStyleInfo() {ReadOnly=true}
};
// adding the custom columns to GanttGrid(Table)
Gantt.GanttGrid.Columns.Add(column);
} |
Hello Sridevi Sivakumar ,
Thank you for your help on this.
I need two more things :
1) my previous explanation was not detailed, I need to have a schedule view of the hours in one day. For that I used "ScheduleType="DayWithHours""
It works well, but when I start the application, I need to have a view of one particular day and the numbers of hours like this :
How can I always show all the hours of a day when the application start and still be able to navigate to the previous or next day in runtime.
2) in the preview screenshot, the day is represented by the first letter of it's name. I need 2 options here :
a) How can I show the entire word of the day ?
b) How can I hide this header ?
Thank you and best regards.
Nicolas
<gantt:GanttControl x:Name="Gantt" Loaded="Gantt_Loaded"
ItemsSource="{Binding Ranges}"
ShowDateWithTime="True"
ShowNonWorkingHoursBackground="False"
ShowChartLines="False"
ToolTipTemplate="{StaticResource toolTipTemplate}"
VisualStyle="Metro"
RowHeight="25" StartTime="01/07/2021"
ScheduleType="DayWithHours"
ScheduleCellCreated="Gantt_ScheduleCellCreated"> |
Gantt.ScrollGanttChartTo("Add your expected date here"); |
<gantt:GanttControl x:Name="Gantt" Loaded="Gantt_Loaded"
ItemsSource="{Binding Ranges}"
ShowDateWithTime="True"
ShowNonWorkingHoursBackground="False"
ShowChartLines="False"
ToolTipTemplate="{StaticResource toolTipTemplate}"
VisualStyle="Metro"
RowHeight="25"
ScheduleType="DayWithHours"
ScheduleCellCreated="Gantt_ScheduleCellCreated"> |
private void Gantt_ScheduleCellCreated(object sender, Syncfusion.Windows.Controls.Gantt.ScheduleCellCreatedEventArgs args)
{
List<string> list = new List<string>() { "M", "T", "W", "S", "F" };
if (list.Contains(args.CurrentCell.Content.ToString()))
{
args.CurrentCell.Content = (args.CurrentCell.CellDate).DayOfWeek;
}
} |
Hi Sridevi Sivakumar,
first of all sorry for my late response.
Second, the explanations are very good and they work as expected for now.
Thank you.
Have a nice day.
Hello,
I still have a strange behavior about the sample we used in this thread and it seems to occur with .netcore 3.1 and .net 5.
Th project in .net framework 4.6 actually works.
In 3.1 or .net 5 (dll version : 19.2.0.44 .NET Core 3.1 and .net5), when I want to delete or create new columns in the gant grid, it seems that the columns are not initialized yet.
When I debug, the loaded event is fired on the ganttcontrol then in the gantcontrol.GantGrid but the columns are not initialized yet...
Can you check this sample and tell me what I do wrong ?
Thank you very much
Best Regards,
Nicolas
private void GanttTmp_Loaded(object sender, RoutedEventArgs e)
{
this.GanttTmp.GanttGrid.Loaded += GanttGrid_Loaded;
}
private void GanttGrid_Loaded(object sender, RoutedEventArgs e)
{
this.GanttTmp.GanttGrid.ItemsSourceChanged += GanttGrid_ItemsSourceChanged;
}
private void GanttGrid_ItemsSourceChanged(object sender, Syncfusion.Windows.ComponentModel.SyncfusionRoutedEventArgs args)
{
for (int i = 0; i < GanttTmp.GanttGrid.Columns.Count; i++)
{
if (GanttTmp.GanttGrid.Columns[i].HeaderText == "Start" || GanttTmp.GanttGrid.Columns[i].HeaderText == "Finish")
{
GanttTmp.GanttGrid.Columns.RemoveAt(i);
i--;
}
else if (GanttTmp.GanttGrid.Columns[i].HeaderText == "Task Name")
{
GanttTmp.GanttGrid.Columns[i].HeaderText = "Activity";
}
else if (GanttTmp.GanttGrid.Columns[i].HeaderText == "Duration")
{
GanttTmp.GanttGrid.Columns[i].HeaderText = "Tots.";
}
}
…
} |
Hello Vignesh Ramesh,
Thank you that's perfect.
I think that there is a last question for you about my requirement.
I have improved the sample to ask you how to achieve a final behavior: is it possible to hide the ScheduleHeader?
See in the attached sample, the second Gantt control have to be as simple as possible and I have to hide the ScheduleHeader like the header of the GanttGrid.
Is it possible?
If not, Is there a workaround? For example go back to one GanttControl and insert a blank row?
Thank you for your advice !
Have a great day,
Best Regards
Nicolas
[C#]
private void GanttGrid_Loaded1(object sender, RoutedEventArgs e)
{
GanttSchedule ganttSchedule = GanttB.FindElementOfType<GanttSchedule>() ;
if (ganttSchedule != null)
{
ganttSchedule.Height = 0;
}
} |
That's it.
I thought I had try it before, obviously I did not.
Thanks !