Generate event markers in Gantt

I know there is no feature of reading event markers from external data. While suggesting you this feature, I would like to get some clue about how to turn a list with Day, Label, CssClass to the gantt event markers tags. For example, turn this list:

List<MarkerData> Markers = new List<MarkerData>(){new MarkerData(){ Day = new DateTime(2025,01,30), Label = 

"Testing", CssClass =

"e-custom-event-marker" },

new MarkerData(){ Day = new DateTime(2025,02,01), Label = "Testing2", CssClass =

"e-custom-event-marker" }

}  

to these tags programmatically:

<GanttEventMarkers>

<GanttEventMarker Day="new DateTime(2025,01,30)" Label="Testing" CssClass="e-custom-event-marker">

</GanttEventMarker>

<GanttEventMarker Day="new DateTime(2025,02,01)" Label="Testing2" CssClass="e-custom-event-marker">

</GanttEventMarker>

</GanttEventMarkers>

I guess the dynamic codes can be created by jQuery? Or is there a more preferred solution?


3 Replies 1 reply marked as answer

AG Ajithkumar Gopalakrishnan Syncfusion Team February 5, 2025 06:56 AM UTC

Hi Desmond,

Greetings from Syncfusion Support,

To achieve your requirement, we suggest using the EventMarkers property in the Gantt chart. This property allows you to pass a collection of event markers to the Gantt chart. We have attached a code snippet and sample for your reference:

<SfGantt EventMarkers="ganttEventMarkers">

   

</SfGantt>

private List<GanttEventMarker> ganttEventMarkers = new List<GanttEventMarker>()

{

    new GanttEventMarker { Day = new DateTime(2021, 04, 09), Label = "Research phase", CssClass = "e-custom-event-marker" },

};


Sample link: https://blazorplayground.syncfusion.com/embed/rXhoZLteVNcQwjcX?appbar=true&editor=true&result=true&errorlist=true&theme=bootstrap5

For more information, you may refer to the following link:

https://blazor.syncfusion.com/documentation/gantt-chart/event-markers

https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Gantt.SfGantt-1.html#Syncfusion_Blazor_Gantt_SfGantt_1_EventMarkers

If you have any further questions or need additional assistance, please let me know!

Regards,
Ajithkumar G


Marked as answer

DE desmond replied to Ajithkumar Gopalakrishnan February 5, 2025 02:30 PM UTC

Thanks a lot for the quick reply that solved the question. I discovered another problem, which I will ask in another thread.



SS Shereen Shajahan Syncfusion Team February 6, 2025 05:00 AM UTC

Hi Desmond,

We're glad we could assist you in resolving your initial query and are happy to help with your new concern in the other thread. For now, we are marking this forum as solved.

Regards,

Shereen


Loader.
Up arrow icon