11---
22layout : post
3- title : Column template in Blazor Gantt Chart Component | Syncfusion
4- description : Checkout and learn here all about column template in Syncfusion Blazor Gantt Chart component and much more details.
3+ title : Column Template in Blazor Gantt Chart Component | Syncfusion
4+ description : Checkout and learn here all about Column Template in Syncfusion Blazor Gantt Chart component and much more details.
55platform : Blazor
66control : Gantt Chart
77documentation : ug
@@ -11,29 +11,30 @@ documentation: ug
1111
1212A column template is used to customize the column’s look. The following code example explains how to define the custom template in Gantt Chart using the ` Template ` property.
1313
14- > ** Note** : The column template feature is used to render the customized element value in the UI for a particular column. The data operations like filtering, sorting, etc., will not work based on the column template values. It will be handled based on the values you have provided to the particular column in the datasource.
14+ N> The column template feature is used to render the customized element value in the UI for a particular column. The data operations like filtering, sorting, etc., will not work based on the column template values. It will be handled based on the values you have provided to the particular column in the datasource.
15+
16+ {% tabs %}
17+ {% highlight razor tabtitle="Index.razor" %}
1518
16- ``` cshtml
1719@using Syncfusion.Blazor.Gantt
1820@using Syncfusion.Blazor.Buttons
1921
2022<SfGantt DataSource =" @TaskCollection " Height =" 450px " Width =" 100% " HighlightWeekends =" true " ProjectStartDate =" @ProjectStart " ProjectEndDate =" @ProjectEnd " >
2123 <GanttColumns>
22- <GanttColumn Field="TaskId " HeaderText="Task ID" MinWidth="150" MaxWidth="250" AllowReordering="false"></GanttColumn>
24+ <GanttColumn Field="TaskID " HeaderText="Task ID" MinWidth="150" MaxWidth="250" AllowReordering="false"></GanttColumn>
2325 <GanttColumn Field="TaskName" HeaderText="Task Name">
2426 <Template>
2527 @{
26- var task = context as TaskData;
27- if (task != null)
28+ @if (context != null)
2829 {
29- <SfButton CssClass="e-bigger" Content="@task .TaskName"></SfButton>
30+ <SfButton CssClass="e-bigger" Content="@((context as TaskData) .TaskName) "></SfButton>
3031 }
3132 }
3233 </Template>
3334 </GanttColumn>
3435 <GanttColumn Field="Duration" HeaderText="Duration"></GanttColumn>
3536 </GanttColumns>
36- <GanttTaskFields Id="TaskId " Name="TaskName" StartDate="StartDate" EndDate="EndDate" Duration="Duration" Progress="Progress" ParentID="ParentId ">
37+ <GanttTaskFields Id="TaskID " Name="TaskName" StartDate="StartDate" EndDate="EndDate" Duration="Duration" Progress="Progress" ParentID="ParentID ">
3738 </GanttTaskFields>
3839</SfGantt >
3940
@@ -49,37 +50,32 @@ A column template is used to customize the column’s look. The following code e
4950
5051 public class TaskData
5152 {
52- public int TaskId { get; set; }
53+ public int TaskID { get; set; }
5354 public string TaskName { get; set; }
5455 public DateTime? StartDate { get; set; }
5556 public DateTime? EndDate { get; set; }
5657 public string Duration { get; set; }
5758 public int Progress { get; set; }
58- public int? ParentId { get; set; }
59+ public int? ParentID { get; set; }
5960 }
6061
6162 public static List<TaskData> GetTaskCollection()
6263 {
63- List<TaskData> Tasks = new List<TaskData>()
64- {
65- new TaskData() { TaskId = 1, TaskName = "Project initiation", StartDate = new DateTime(2022, 04, 05), EndDate = new DateTime(2022, 04, 21) },
66- new TaskData() { TaskId = 2, TaskName = "Identify site location", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentId = 1 },
67- new TaskData() { TaskId = 3, TaskName = "Perform soil test", StartDate = new DateTime(2022, 04, 05), Duration = "4", Progress = 40, ParentId = 1 },
68- new TaskData() { TaskId = 4, TaskName = "Soil test approval", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentId = 1 },
69- new TaskData() { TaskId = 5, TaskName = "Project estimation", StartDate = new DateTime(2022, 04, 06), EndDate = new DateTime(2022, 04, 21) },
70- new TaskData() { TaskId = 6, TaskName = "Develop floor plan for estimation", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 30, ParentId = 5 },
71- new TaskData() { TaskId = 7, TaskName = "List materials", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 40, ParentId = 5 },
72- new TaskData() { TaskId = 8, TaskName = "Estimation approval", StartDate = new DateTime(2022, 04, 06), Duration = "0", Progress = 30, ParentId = 5 }
73- };
64+ List<TaskData> Tasks = new List<TaskData>() {
65+ new TaskData() { TaskID = 1, TaskName = "Project initiation", StartDate = new DateTime(2022, 04, 05), EndDate = new DateTime(2022, 04, 08) },
66+ new TaskData() { TaskID = 2, TaskName = "Identify Site location", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentID = 1 },
67+ new TaskData() { TaskID = 3, TaskName = "Perform soil test", StartDate = new DateTime(2022, 04, 05), Duration = "4", Progress = 40, ParentID = 1 },
68+ new TaskData() { TaskID = 4, TaskName = "Soil test approval", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentID = 1 },
69+ new TaskData() { TaskID = 5, TaskName = "Project estimation", StartDate = new DateTime(2022, 04, 06), EndDate = new DateTime(2022, 04, 08) },
70+ new TaskData() { TaskID = 6, TaskName = "Develop floor plan for estimation", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 30, ParentID = 5 },
71+ new TaskData() { TaskID = 7, TaskName = "List materials", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 40, ParentID = 5 },
72+ new TaskData() { TaskID = 8, TaskName = "Estimation approval", StartDate = new DateTime(2022, 04, 06), Duration = "0", Progress = 30, ParentID = 5 }
73+ };
7474 return Tasks;
7575 }
7676}
77- ```
78-
79- ![ Blazor Gantt Chart with column template showing task names as buttons] ( images/blazor-gantt-chart-column-template.png )
8077
81- ## See also
78+ {% endhighlight %}
79+ {% endtabs %}
8280
83- - [ Accessibility in Blazor Gantt Chart] ( https://blazor.syncfusion.com/documentation/gantt-chart/accessibility )
84- - [ Blazor Gantt Chart Feature Tour] ( https://www.syncfusion.com/blazor-components/blazor-gantt-chart )
85- - [ Blazor Gantt Chart Example] ( https://blazor.syncfusion.com/demos/gantt-chart/default-functionalities?theme=bootstrap5 )
81+ {% previewsample "https://blazorplayground.syncfusion.com/embed/rjryZkBnBTRdmaLS?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5 " %}
0 commit comments