Skip to content

Commit fac6df6

Browse files
908232: Added PDF UG
1 parent f14de31 commit fac6df6

File tree

8 files changed

+653
-24
lines changed

8 files changed

+653
-24
lines changed

blazor/gantt-chart/events.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3876,4 +3876,153 @@ The events should be provided to the Gantt Chart using the GanttChartEvents comp
38763876
}
38773877
```
38783878

3879+
## PdfExporting
3880+
3881+
The [PdfExporting](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Gantt.GanttEvents-1.html#Syncfusion_Blazor_Gantt_GanttEvents_1_PdfExporting) event triggers before the Gantt chart is exported to a PDF document. To cancel the export, set the `Cancel` argument to true within the `PdfExporting` event, using the `PdfExportEventArgs` class.
3882+
3883+
``` cshtml
3884+
@using Syncfusion.Blazor.Gantt
3885+
@using Syncfusion.Blazor.Grids
3886+
@using Syncfusion.Blazor.Navigations
3887+
@using Syncfusion.PdfExport
3888+
3889+
<SfGantt @ref="Gantt" ID="GanttExport" DataSource="@TaskCollection" Height="450px" Width="900px" AllowPdfExport="true" Toolbar="toolbarItem">
3890+
<GanttTaskFields Id="TaskId" Name="TaskName" StartDate="StartDate" EndDate="EndDate" Dependency="Predecessor"
3891+
Duration="Duration" Progress="Progress" ParentID="ParentId">
3892+
</GanttTaskFields>
3893+
<GanttColumns>
3894+
<GanttColumn Field="TaskId" HeaderText="Task Id" Width="100" HeaderTextAlign="Syncfusion.Blazor.Grids.TextAlign.Right"></GanttColumn>
3895+
<GanttColumn Field="TaskName" HeaderText="Task Name"></GanttColumn>
3896+
<GanttColumn Field="StartDate" HeaderText="Start Date" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right"></GanttColumn>
3897+
<GanttColumn Field="EndDate" HeaderText="End Date"></GanttColumn>
3898+
<GanttColumn Field="Duration" HeaderText="Duration"></GanttColumn>
3899+
<GanttColumn Field="Predecessor" HeaderText="Dependency"></GanttColumn>
3900+
</GanttColumns>
3901+
<GanttEvents OnToolbarClick="ToolbarClickHandler" PdfExporting=" PdfExportingHandler" TValue="TaskData"></GanttEvents>
3902+
</SfGantt>
3903+
3904+
@code {
3905+
private List<TaskData> TaskCollection { get; set; }
3906+
private SfGantt<TaskData> Gantt;
3907+
private List<object> toolbarItem = new List<Object>() { new ToolbarItem() { Text = "PDF Export", TooltipText = "PDF Export", Id = "PdfExport", PrefixIcon = "e-pdfexport" } };
3908+
protected override void OnInitialized()
3909+
{
3910+
this.TaskCollection = GetTaskCollection();
3911+
}
3912+
public async void ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)
3913+
{
3914+
if (args.Item.Id == "PdfExport")
3915+
{
3916+
await Gantt.ExportToPdfAsync();
3917+
}
3918+
}
3919+
public void PdfExportingHandler(PdfExportEventArgs args)
3920+
{
3921+
//Here, you can customize your code.
3922+
}
3923+
public class TaskData
3924+
{
3925+
public int TaskId { get; set; }
3926+
public string TaskName { get; set; }
3927+
public DateTime StartDate { get; set; }
3928+
public DateTime? EndDate { get; set; }
3929+
public string Duration { get; set; }
3930+
public int Progress { get; set; }
3931+
public int? ParentId { get; set; }
3932+
public string Predecessor { get; set; }
3933+
}
3934+
3935+
public static List<TaskData> GetTaskCollection()
3936+
{
3937+
List<TaskData> Tasks = new List<TaskData>()
3938+
{
3939+
new TaskData() { TaskId = 1, TaskName = "Project initiation", StartDate = new DateTime(2022, 04, 05), EndDate = new DateTime(2022, 04, 21), },
3940+
new TaskData() { TaskId = 2, TaskName = "Identify Site location", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentId = 1 },
3941+
new TaskData() { TaskId = 3, TaskName = "Perform soil test", StartDate = new DateTime(2022, 04, 05), Duration = "4", Progress = 40, ParentId = 1, Predecessor = "2" },
3942+
new TaskData() { TaskId = 4, TaskName = "Soil test approval", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentId = 1 , Predecessor = "3" },
3943+
new TaskData() { TaskId = 5, TaskName = "Project estimation", StartDate = new DateTime(2022, 04, 06), EndDate = new DateTime(2022, 04, 21), },
3944+
new TaskData() { TaskId = 6, TaskName = "Develop floor plan for estimation", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 30, ParentId = 5 },
3945+
new TaskData() { TaskId = 7, TaskName = "List materials", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 40, ParentId = 5 },
3946+
new TaskData() { TaskId = 8, TaskName = "Estimation approval", StartDate = new DateTime(2022, 04, 06), Duration = "0", Progress = 30, ParentId = 5 }
3947+
};
3948+
return Tasks;
3949+
}
3950+
}
3951+
```
3952+
3953+
## PdfExported
3954+
3955+
The [PdfExported](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Gantt.GanttEvents-1.html#Syncfusion_Blazor_Gantt_GanttEvents_1_PdfExported) event triggers after the Gantt chart is exported to a PDF document. Using event arguments, you can get the details of the exported columns, the timeline range of the exported Gantt chart, and the file name of the exported PDF document.
3956+
3957+
``` cshtml
3958+
@using Syncfusion.Blazor.Gantt
3959+
@using Syncfusion.Blazor.Grids
3960+
@using Syncfusion.Blazor.Navigations
3961+
@using Syncfusion.PdfExport
3962+
3963+
<SfGantt @ref="Gantt" ID="GanttExport" DataSource="@TaskCollection" Height="450px" Width="900px" AllowPdfExport="true" Toolbar="toolbarItem">
3964+
<GanttTaskFields Id="TaskId" Name="TaskName" StartDate="StartDate" EndDate="EndDate" Dependency="Predecessor"
3965+
Duration="Duration" Progress="Progress" ParentID="ParentId">
3966+
</GanttTaskFields>
3967+
<GanttColumns>
3968+
<GanttColumn Field="TaskId" HeaderText="Task Id" Width="100" HeaderTextAlign="Syncfusion.Blazor.Grids.TextAlign.Right"></GanttColumn>
3969+
<GanttColumn Field="TaskName" HeaderText="Task Name"></GanttColumn>
3970+
<GanttColumn Field="StartDate" HeaderText="Start Date" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right"></GanttColumn>
3971+
<GanttColumn Field="EndDate" HeaderText="End Date"></GanttColumn>
3972+
<GanttColumn Field="Duration" HeaderText="Duration"></GanttColumn>
3973+
<GanttColumn Field="Predecessor" HeaderText="Dependency"></GanttColumn>
3974+
</GanttColumns>
3975+
<GanttEvents OnToolbarClick="ToolbarClickHandler" PdfExported=" PdfExportedHandler" TValue="TaskData"></GanttEvents>
3976+
</SfGantt>
3977+
3978+
@code {
3979+
private List<TaskData> TaskCollection { get; set; }
3980+
private SfGantt<TaskData> Gantt;
3981+
private List<object> toolbarItem = new List<Object>() { new ToolbarItem() { Text = "PDF Export", TooltipText = "PDF Export", Id = "PdfExport", PrefixIcon = "e-pdfexport" } };
3982+
protected override void OnInitialized()
3983+
{
3984+
this.TaskCollection = GetTaskCollection();
3985+
}
3986+
public async void ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)
3987+
{
3988+
if (args.Item.Id == "PdfExport")
3989+
{
3990+
await Gantt.ExportToPdfAsync();
3991+
}
3992+
}
3993+
public void PdfExportedHandler(PdfExportedEventArgs args)
3994+
{
3995+
//Here, you can customize your code.
3996+
}
3997+
public class TaskData
3998+
{
3999+
public int TaskId { get; set; }
4000+
public string TaskName { get; set; }
4001+
public DateTime StartDate { get; set; }
4002+
public DateTime? EndDate { get; set; }
4003+
public string Duration { get; set; }
4004+
public int Progress { get; set; }
4005+
public int? ParentId { get; set; }
4006+
public string Predecessor { get; set; }
4007+
}
4008+
4009+
public static List<TaskData> GetTaskCollection()
4010+
{
4011+
List<TaskData> Tasks = new List<TaskData>()
4012+
{
4013+
new TaskData() { TaskId = 1, TaskName = "Project initiation", StartDate = new DateTime(2022, 04, 05), EndDate = new DateTime(2022, 04, 21), },
4014+
new TaskData() { TaskId = 2, TaskName = "Identify Site location", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentId = 1 },
4015+
new TaskData() { TaskId = 3, TaskName = "Perform soil test", StartDate = new DateTime(2022, 04, 05), Duration = "4", Progress = 40, ParentId = 1, Predecessor = "2" },
4016+
new TaskData() { TaskId = 4, TaskName = "Soil test approval", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentId = 1 , Predecessor = "3" },
4017+
new TaskData() { TaskId = 5, TaskName = "Project estimation", StartDate = new DateTime(2022, 04, 06), EndDate = new DateTime(2022, 04, 21), },
4018+
new TaskData() { TaskId = 6, TaskName = "Develop floor plan for estimation", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 30, ParentId = 5 },
4019+
new TaskData() { TaskId = 7, TaskName = "List materials", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 40, ParentId = 5 },
4020+
new TaskData() { TaskId = 8, TaskName = "Estimation approval", StartDate = new DateTime(2022, 04, 06), Duration = "0", Progress = 30, ParentId = 5 }
4021+
};
4022+
return Tasks;
4023+
}
4024+
}
4025+
```
4026+
4027+
38794028
N> We are not going to limit Gantt Chart with these events, we will be adding new events in the future based on the user requests. If the event, you are looking for is not on the list, then request [here](https://www.syncfusion.com/feedback/blazor-components).
63.1 KB
Loading
39 KB
Loading
54.9 KB
Loading
71.3 KB
Loading
68.2 KB
Loading

0 commit comments

Comments
 (0)