Skip to content

Commit e465519

Browse files
Merge pull request #6615 from syncfusion-content/982155-part1-code
982155: Part 1 - Check code snippet and make preview sample in blazor
2 parents 92899a4 + 956727d commit e465519

33 files changed

+589
-1016
lines changed

blazor/gantt-chart/adding-new-tasks.md

Lines changed: 56 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ Tasks can be dynamically added to the Gantt Chart project by enabling the [Gantt
1515

1616
A row can be added to the Gantt Chart component from the toolbar while the `GanttEditSettings.AllowAdding` property is set to `true`. After clicking the toolbar add icon, you should provide the task information in the add dialog.
1717

18-
```cshtml
18+
{% tabs %}
19+
{% highlight razor tabtitle="Index.razor" %}
20+
1921
@using Syncfusion.Blazor.Gantt
2022
<SfGantt DataSource="@TaskCollection" Toolbar="@(new List<string>() { "Add" })" Height="450px" Width="900px">
21-
<GanttTaskFields Id="TaskId" Name="TaskName" StartDate="StartDate" EndDate="EndDate" Duration="Duration" Progress="Progress" ParentID="ParentId">
23+
<GanttTaskFields Id="TaskID" Name="TaskName" StartDate="StartDate" EndDate="EndDate" Duration="Duration" Progress="Progress" ParentID="ParentID">
2224
</GanttTaskFields>
2325
<GanttEditSettings AllowAdding="true"></GanttEditSettings>
2426
</SfGantt>
@@ -32,46 +34,49 @@ A row can be added to the Gantt Chart component from the toolbar while the `Gant
3234

3335
public class TaskData
3436
{
35-
public int TaskId { get; set; }
37+
public int TaskID { get; set; }
3638
public string TaskName { get; set; }
3739
public DateTime StartDate { get; set; }
3840
public DateTime? EndDate { get; set; }
3941
public string Duration { get; set; }
4042
public int Progress { get; set; }
41-
public int? ParentId { get; set; }
43+
public int? ParentID { get; set; }
4244
}
4345

4446
public static List<TaskData> GetTaskCollection()
4547
{
4648
List<TaskData> Tasks = new List<TaskData>()
4749
{
48-
new TaskData() { TaskId = 1, TaskName = "Project initiation", StartDate = new DateTime(2022, 04, 05), EndDate = new DateTime(2022, 04, 21), },
49-
new TaskData() { TaskId = 2, TaskName = "Identify Site location", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentId = 1 },
50-
new TaskData() { TaskId = 3, TaskName = "Perform soil test", StartDate = new DateTime(2022, 04, 05), Duration = "4", Progress = 40, ParentId = 1 },
51-
new TaskData() { TaskId = 4, TaskName = "Soil test approval", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentId = 1 },
52-
new TaskData() { TaskId = 5, TaskName = "Project estimation", StartDate = new DateTime(2022, 04, 06), EndDate = new DateTime(2022, 04, 21), },
53-
new TaskData() { TaskId = 6, TaskName = "Develop floor plan for estimation", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 30, ParentId = 5 },
54-
new TaskData() { TaskId = 7, TaskName = "List materials", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 40, ParentId = 5 },
55-
new TaskData() { TaskId = 8, TaskName = "Estimation approval", StartDate = new DateTime(2022, 04, 06), Duration = "0", Progress = 30, ParentId = 5 }
50+
new TaskData() { TaskID = 1, TaskName = "Project initiation", StartDate = new DateTime(2022, 04, 05), EndDate = new DateTime(2022, 04, 08), },
51+
new TaskData() { TaskID = 2, TaskName = "Identify Site location", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentID = 1 },
52+
new TaskData() { TaskID = 3, TaskName = "Perform soil test", StartDate = new DateTime(2022, 04, 05), Duration = "4", Progress = 40, ParentID = 1 },
53+
new TaskData() { TaskID = 4, TaskName = "Soil test approval", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentID = 1 },
54+
new TaskData() { TaskID = 5, TaskName = "Project estimation", StartDate = new DateTime(2022, 04, 06), EndDate = new DateTime(2022, 04, 08), },
55+
new TaskData() { TaskID = 6, TaskName = "Develop floor plan for estimation", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 30, ParentID = 5 },
56+
new TaskData() { TaskID = 7, TaskName = "List materials", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 40, ParentID = 5 },
57+
new TaskData() { TaskID = 8, TaskName = "Estimation approval", StartDate = new DateTime(2022, 04, 06), Duration = "0", Progress = 30, ParentID = 5 }
5658
};
5759
return Tasks;
5860
}
5961
}
60-
```
6162

62-
![Adding New Task in Blazor Gantt Chart](images/blazor-gantt-chart-add-new-row.png)
63+
{% endhighlight %}
64+
{% endtabs %}
65+
66+
{% previewsample "https://blazorplayground.syncfusion.com/embed/hZLIjkMxqOcLSDUD?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %}
6367

6468
N> By default, a new row will be added to the top most row in the Gantt Chart component.
6569

6670
## Context menu
6771

6872
A row can also be added above, below or child of the selected row by using context menu support. For this, you need to enable the property `EnableContextMenu`.
6973

70-
```cshtml
74+
{% tabs %}
75+
{% highlight razor tabtitle="Index.razor" %}
76+
7177
@using Syncfusion.Blazor.Gantt
7278
<SfGantt DataSource="@TaskCollection" Height="450px" EnableContextMenu="true" Width="900px" HighlightWeekends="true">
73-
<GanttTaskFields Id="TaskId" Name="TaskName" StartDate="StartDate" EndDate="EndDate" Duration="Duration" Progress="Progress"
74-
Dependency="Predecessor" ParentID="ParentId"></GanttTaskFields>
79+
<GanttTaskFields Id="TaskID" Name="TaskName" StartDate="StartDate" EndDate="EndDate" Duration="Duration" Progress="Progress" Dependency="Predecessor" ParentID="ParentID"></GanttTaskFields>
7580
<GanttEditSettings AllowAdding="true"></GanttEditSettings>
7681
</SfGantt>
7782

@@ -83,32 +88,36 @@ A row can also be added above, below or child of the selected row by using conte
8388
}
8489
public class TaskData
8590
{
86-
public int TaskId { get; set; }
91+
public int TaskID { get; set; }
8792
public string TaskName { get; set; }
8893
public DateTime StartDate { get; set; }
8994
public DateTime? EndDate { get; set; }
9095
public string Duration { get; set; }
9196
public double Progress { get; set; }
9297
public string Predecessor { get; set; }
93-
public int? ParentId { get; set; }
98+
public int? ParentID { get; set; }
9499
}
95100

96101
public static List<TaskData> GetTaskCollection()
97102
{
98103
List<TaskData> Tasks = new List<TaskData>() {
99-
new TaskData() { TaskId = 1, TaskName = "Project initiation", StartDate = new DateTime(2022, 04, 05), EndDate = new DateTime(2022, 04, 21) },
100-
new TaskData() { TaskId = 2, TaskName = "Identify Site location", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentId = 1 },
101-
new TaskData() { TaskId = 3, TaskName = "Perform soil test", StartDate = new DateTime(2022, 04, 05), Duration = "4", Progress = 40, ParentId = 1 },
102-
new TaskData() { TaskId = 4, TaskName = "Soil test approval", StartDate = new DateTime(2022, 04, 05), Duration = "3", Progress = 30, Predecessor = "2", ParentId = 1 },
103-
new TaskData() { TaskId = 5, TaskName = "Project estimation", StartDate = new DateTime(2022, 04, 06), EndDate = new DateTime(2022, 04, 21) },
104-
new TaskData() { TaskId = 6, TaskName = "Develop floor plan for estimation", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 30, ParentId = 5 },
105-
new TaskData() { TaskId = 7, TaskName = "List materials", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 40, ParentId = 5 },
106-
new TaskData() { TaskId = 8, TaskName = "Estimation approval", StartDate = new DateTime(2022, 04, 06), Duration = "0", Progress = 30, Predecessor = "6", ParentId = 5 }
104+
new TaskData() { TaskID = 1, TaskName = "Project initiation", StartDate = new DateTime(2022, 04, 05), EndDate = new DateTime(2022, 04, 08) },
105+
new TaskData() { TaskID = 2, TaskName = "Identify Site location", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentID = 1 },
106+
new TaskData() { TaskID = 3, TaskName = "Perform soil test", StartDate = new DateTime(2022, 04, 05), Duration = "4", Progress = 40, ParentID = 1 },
107+
new TaskData() { TaskID = 4, TaskName = "Soil test approval", StartDate = new DateTime(2022, 04, 05), Duration = "3", Progress = 30, Predecessor = "2", ParentID = 1 },
108+
new TaskData() { TaskID = 5, TaskName = "Project estimation", StartDate = new DateTime(2022, 04, 06), EndDate = new DateTime(2022, 04, 08) },
109+
new TaskData() { TaskID = 6, TaskName = "Develop floor plan for estimation", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 30, ParentID = 5 },
110+
new TaskData() { TaskID = 7, TaskName = "List materials", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 40, ParentID = 5 },
111+
new TaskData() { TaskID = 8, TaskName = "Estimation approval", StartDate = new DateTime(2022, 04, 06), Duration = "0", Progress = 30, Predecessor = "6", ParentID = 5 }
107112
};
108113
return Tasks;
109114
}
110115
}
111-
```
116+
117+
{% endhighlight %}
118+
{% endtabs %}
119+
120+
{% previewsample "https://blazorplayground.syncfusion.com/embed/rZhIjYMHJtqJyIRP?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %}
112121

113122
## Using method
114123

@@ -120,19 +129,21 @@ You can add rows to the Gantt Chart component dynamically using the [AddRecordAs
120129
* Below the selected row.
121130
* As child to the selected row.
122131

123-
```cshtml
132+
{% tabs %}
133+
{% highlight razor tabtitle="Index.razor" %}
134+
124135
@using Syncfusion.Blazor.Gantt
125136
@using Syncfusion.Blazor.Buttons
126137
<SfButton @onclick="AddRow">Add Row</SfButton>
127138
<SfGantt @ref="Gantt" DataSource="@TaskCollection" Height="450px" Width="900px">
128-
<GanttTaskFields Id="TaskId" Name="TaskName" StartDate="StartDate" EndDate="EndDate" Duration="Duration" Progress="Progress" ParentID="ParentId">
139+
<GanttTaskFields Id="TaskID" Name="TaskName" StartDate="StartDate" EndDate="EndDate" Duration="Duration" Progress="Progress" ParentID="ParentID">
129140
</GanttTaskFields>
130141
<GanttEditSettings AllowAdding="true"></GanttEditSettings>
131142
</SfGantt>
132143

133144
@code{
134145
public SfGantt<TaskData> Gantt;
135-
public TaskData record = new TaskData() { TaskId = 9, TaskName = "New Added Record", StartDate = new DateTime(2022, 04, 05), Duration = "3", Progress = 50};
146+
public TaskData record = new TaskData() { TaskID = 9, TaskName = "New Added Record", StartDate = new DateTime(2022, 04, 05), Duration = "3", Progress = 50};
136147

137148
public void AddRow()
138149
{
@@ -146,29 +157,31 @@ You can add rows to the Gantt Chart component dynamically using the [AddRecordAs
146157

147158
public class TaskData
148159
{
149-
public int TaskId { get; set; }
160+
public int TaskID { get; set; }
150161
public string TaskName { get; set; }
151162
public DateTime StartDate { get; set; }
152163
public DateTime? EndDate { get; set; }
153164
public string Duration { get; set; }
154165
public int Progress { get; set; }
155-
public int? ParentId { get; set; }
166+
public int? ParentID { get; set; }
156167
}
157168

158169
public static List <TaskData> GetTaskCollection() {
159170
List <TaskData> Tasks = new List <TaskData> () {
160-
new TaskData() { TaskId = 1, TaskName = "Project initiation", StartDate = new DateTime(2022, 04, 05), EndDate = new DateTime(2022, 04, 21) },
161-
new TaskData() { TaskId = 2, TaskName = "Identify Site location", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentId = 1 },
162-
new TaskData() { TaskId = 3, TaskName = "Perform soil test", StartDate = new DateTime(2022, 04, 05), Duration = "4", Progress = 40, ParentId = 1 },
163-
new TaskData() { TaskId = 4, TaskName = "Soil test approval", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentId = 1 },
164-
new TaskData() { TaskId = 5, TaskName = "Project estimation", StartDate = new DateTime(2022, 04, 06), EndDate = new DateTime(2022, 04, 21) },
165-
new TaskData() { TaskId = 6, TaskName = "Develop floor plan for estimation", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 30, ParentId = 5 },
166-
new TaskData() { TaskId = 7, TaskName = "List materials", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 40, ParentId = 5 },
167-
new TaskData() { TaskId = 8, TaskName = "Estimation approval", StartDate = new DateTime(2022, 04, 06), Duration = "0", Progress = 30, ParentId = 5 }
171+
new TaskData() { TaskID = 1, TaskName = "Project initiation", StartDate = new DateTime(2022, 04, 05), EndDate = new DateTime(2022, 04, 08) },
172+
new TaskData() { TaskID = 2, TaskName = "Identify Site location", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentID = 1 },
173+
new TaskData() { TaskID = 3, TaskName = "Perform soil test", StartDate = new DateTime(2022, 04, 05), Duration = "4", Progress = 40, ParentID = 1 },
174+
new TaskData() { TaskID = 4, TaskName = "Soil test approval", StartDate = new DateTime(2022, 04, 05), Duration = "0", Progress = 30, ParentID = 1 },
175+
new TaskData() { TaskID = 5, TaskName = "Project estimation", StartDate = new DateTime(2022, 04, 06), EndDate = new DateTime(2022, 04, 08) },
176+
new TaskData() { TaskID = 6, TaskName = "Develop floor plan for estimation", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 30, ParentID = 5 },
177+
new TaskData() { TaskID = 7, TaskName = "List materials", StartDate = new DateTime(2022, 04, 06), Duration = "3", Progress = 40, ParentID = 5 },
178+
new TaskData() { TaskID = 8, TaskName = "Estimation approval", StartDate = new DateTime(2022, 04, 06), Duration = "0", Progress = 30, ParentID = 5 }
168179
};
169180
return Tasks;
170181
}
171182
}
172-
```
173183

174-
![Adding New Record in Blazor Gantt Chart](images/blazor-gantt-chart-add-new-record.png)
184+
{% endhighlight %}
185+
{% endtabs %}
186+
187+
{% previewsample "https://blazorplayground.syncfusion.com/embed/VtVejYiHpDyFanTO?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %}

0 commit comments

Comments
 (0)