Custom Schedule

Hi,

is it possible to change a gantt schedule datetime like in the image attached ?



Best regards
Gian Piero Truccolo

3 Replies 1 reply marked as answer

RS Ramya Soundar Rajan Syncfusion Team May 26, 2021 01:19 PM UTC

Hi Gian Piero Truccolo, 
 
Query 1 and 2: 
 
We have analyzed the provided image and we can be able to achieve it by using CellTextFormat in GanttScheduleRowInfo and Content of CurrentCell in ScheduleCellCreated event arguments. Please find the snippet below  
 
In ViewModel class 
 
this.ScheduleSource1 = new ObservableCollection<GanttScheduleRowInfo> 
        { 
            new GanttScheduleRowInfo { TimeUnit = TimeUnit.Years, CellTextFormat = "yyyy" }, 
            new GanttScheduleRowInfo { TimeUnit = TimeUnit.Months, CellTextFormat = "MMMM" }, 
            new GanttScheduleRowInfo { TimeUnit = TimeUnit.Days, PixelsPerUnit = 20 } 
        }; 
 
 
In MainWindow.xaml.cs 
 
private void GanttControl_ScheduleCellCreated(object sender, ScheduleCellCreatedEventArgs args) 
{ 
    if (args.CurrentCell.CellTimeUnit == TimeUnit.Days) 
    { 
        // To show only the first letter of the day. 
        args.CurrentCell.Content = args.CurrentCell.CellDate.ToString("ddd").Substring(0,1).ToLower(); 
    } 
} 
 
 
NOTE: 
We can set the globalized string format directly to CellTextFormat property of GanttScheduleRowInfo. Otherwise, if we like to display our own string in schedule cell means, we can set it directly to Content property of CurrentCell in ScheduleCellCreated event. 
 
Output 
 
 
 
Query 3: 
 
We can’t be able to change the number of days in month as like you have showed in image 3. But we can merge the cells by using the CellsPerUnit property of GanttScheduleRowInfo as like below snippet. 
 
In ViewModel.cs 
 
this.ScheduleSource3 = new ObservableCollection<GanttScheduleRowInfo> 
        { 
            new GanttScheduleRowInfo { TimeUnit = TimeUnit.Years, CellTextFormat = "yyyy" }, 
            new GanttScheduleRowInfo { TimeUnit = TimeUnit.Months, CellTextFormat = "MM", CellsPerUnit = 3 }, 
            new GanttScheduleRowInfo { TimeUnit = TimeUnit.Days, CellTextFormat = "dd MMM", PixelsPerUnit = 20, CellsPerUnit = 3 } 
        }; 
 
 
Output: 
 
 
Please find the sample from the below link 
 
 
Please find more information about the custom schedule from the below user guide link 
 
Please let us know if you have any queries. 
 
Regards, 
Ramya S 



GI Gian May 27, 2021 02:00 PM UTC

Hi,

is it possible to have the custom schedule as below?



For us every row has progressive numbers.

Best Regards
Gian Piero Truccolo


SS Sridevi Sivakumar Syncfusion Team May 28, 2021 11:31 AM UTC

Hi Gian Piero Truccolo,

We have checked the shared image and we can customize the days by setting the current cell content as CurrentCell.CellDate.DayOfYear as per the below code snippet

[C#]
 
 private void GanttControl_ScheduleCellCreated_1(object sender, ScheduleCellCreatedEventArgs args) 
        { 
            if (args.CurrentCell.CellTimeUnit == TimeUnit.Days) 
            { 
                args.CurrentCell.Content = args.CurrentCell.CellDate.DayOfYear; 
            } 
            string content = args.CurrentCell.Content.ToString(); 
            if (content.Substring(0, 1) == "0") 
            { 
                args.CurrentCell.Content = content.Substring(1, content.Length - 1); 
            } 
        } 

Screenshot:
 

Let us know if you need any further assistance.

Regards,
 
Sridevi S. 
 


Marked as answer
Loader.
Up arrow icon