Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace WebApplication4.Pages
{
public class IndexModel : PageModel
{
public List<GanttDataSource> DataSource { get; set; } = new();

public void OnGet()
{
DataSource = GetGanttData();
}

public static List<GanttDataSource> GetGanttData()
{
return new List<GanttDataSource>
{
// 1. Project Initiation (Parent)
new() {
TaskID = 1,
TaskName = "Project Initiation",
Progress = 100,
Status = "Completed"
},
new() {
TaskID = 2,
TaskName = "Kickoff Meeting",
ParentID = 1,
StartDate = new DateTime(2025, 3, 3),
Duration = 1,
Progress = 100,
Status = "Completed"
},
new() {
TaskID = 3,
TaskName = "Requirements Gathering",
ParentID = 1,
StartDate = new DateTime(2025, 3, 4),
Duration = 3,
Progress = 100,
Status = "Completed"
},

// 4. System Design (Parent)
new() {
TaskID = 4,
TaskName = "System Design",
Progress = 80, // Average of children
Status = "In Progress"
},
new() {
TaskID = 5,
TaskName = "Architecture Design",
ParentID = 4,
StartDate = new DateTime(2025, 3, 7),
Duration = 4,
Progress = 90,
Status = "In Progress"
},
new() {
TaskID = 6,
TaskName = "Database Design",
ParentID = 4,
StartDate = new DateTime(2025, 3, 12),
Duration = 3,
Progress = 70,
Status = "In Progress"
},

// 7. Development Phase (Parent)
new() {
TaskID = 7,
TaskName = "Development Phase",
Progress = 62, // Average
Status = "In Progress"
},
new() {
TaskID = 8,
TaskName = "Backend Development",
ParentID = 7,
StartDate = new DateTime(2025, 3, 15),
Duration = 5,
Progress = 70,
Status = "In Progress"
},
new() {
TaskID = 9,
TaskName = "Frontend Development",
ParentID = 7,
StartDate = new DateTime(2025, 3, 20),
Duration = 5,
Progress = 55,
Status = "In Progress"
},
new() {
TaskID = 10,
TaskName = "API Integration",
ParentID = 7,
StartDate = new DateTime(2025, 3, 25),
Duration = 4,
Progress = 60,
Status = "In Progress"
},

// 11. Testing Cycle (Parent)
new() {
TaskID = 11,
TaskName = "Testing Cycle",
Progress = 60, // Approx average
Status = "In Progress"
},
new() {
TaskID = 12,
TaskName = "Test Planning",
ParentID = 11,
StartDate = new DateTime(2025, 3, 29),
Duration = 3,
Progress = 90,
Status = "In Progress"
},
new() {
TaskID = 13,
TaskName = "Test Execution",
ParentID = 11,
StartDate = new DateTime(2025, 4, 1),
Duration = 4,
Progress = 60,
Status = "In Progress"
},
new() {
TaskID = 14,
TaskName = "Bug Fixing",
ParentID = 11,
StartDate = new DateTime(2025, 4, 5),
Duration = 4,
Progress = 30,
Status = "In Progress"
},

// 15. Deployment & Go-Live (Parent)
new() {
TaskID = 15,
TaskName = "Deployment & Go-Live",
Progress = 0,
Status = "Not Started"
},
new() {
TaskID = 16,
TaskName = "Final Release",
ParentID = 15,
StartDate = new DateTime(2025, 4, 9),
Duration = 3,
Progress = 0,
Status = "Not Started"
}
};
}

public class GanttDataSource
{
public int TaskID { get; set; }
public string? TaskName { get; set; }
public DateTime StartDate { get; set; }
public DateTime? EndDate { get; set; }
public int? Duration { get; set; }
public int? Progress { get; set; }
public string? Predecessor { get; set; }
public int? ParentID { get; set; }
public string? Status { get; set; }

}
}
}
21 changes: 21 additions & 0 deletions ej2-asp-core-mvc/code-snippet/gantt/columns/freezeColumn/razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div id="ganttContainer" style="height:1500px;margin:0;">
@Html.EJS().Gantt("GanttContainer").Height("430px").DataSource((IEnumerable<object>)ViewBag.DataSource).TreeColumnIndex(1).GridLines(Syncfusion.EJ2.Gantt.GridLine.Both).SplitterSettings(s => s.Position("65%")).LabelSettings(l => l.TaskLabel("Progress")).TaskFields(tf =>
{
tf.Id("TaskID")
.Name("TaskName")
.StartDate("StartDate")
.EndDate("EndDate")
.Duration("Duration")
.Progress("Progress")
.Dependency("Predecessor")
.ParentID("ParentID");
}).Columns(col =>
{
col.Field("TaskID").HeaderText("Task ID").IsFrozen(true).Add();
col.Field("TaskName").HeaderText("Task Name").Width("220").IsFrozen(true).Add();
col.Field("StartDate").HeaderText("Start Date").Add();
col.Field("Duration").HeaderText("Duration").Add();
col.Field("Progress").HeaderText("Progress").Add();
col.Field("Status").HeaderText("Status").IsFrozen(true).Add();
}).Render()
</div>
24 changes: 24 additions & 0 deletions ej2-asp-core-mvc/code-snippet/gantt/columns/freezeColumn/tagHelper
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@page
@model IndexModel

<ejs-gantt id="Gantt" dataSource="@Model.DataSource" height="430px" treeColumnIndex="1" gridLines="Both">
<e-gantt-taskfields id="TaskID"
name="TaskName"
startDate="StartDate"
duration="Duration"
endDate="EndDate"
dependency="Predecessor"
progress="Progress"
parentID="ParentID">
</e-gantt-taskfields>
<e-gantt-splitterSettings position="65%"></e-gantt-splitterSettings>
<e-gantt-labelSettings taskLabel="Progress"></e-gantt-labelSettings>
<e-gantt-columns>
<e-gantt-column field="TaskID" headerText="Task ID" isFrozen="true"></e-gantt-column>
<e-gantt-column field="TaskName" headerText="Task Name" width="220" isFrozen="true"></e-gantt-column>
<e-gantt-column field="StartDate" headerText="Start Date"></e-gantt-column>
<e-gantt-column field="Duration" headerText="Duration"></e-gantt-column>
<e-gantt-column field="Progress" headerText="Progress"></e-gantt-column>
<e-gantt-column field="Status" headerText="Status" isFrozen="true"></e-gantt-column>
</e-gantt-columns>
</ejs-gantt>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
public ActionResult Index()
{
ViewBag.DataSource = GanttData();
ViewBag.Resources = GetResources();
return View();
}

private List<ResourceModel> GetResources()
{
return new List<ResourceModel>
{
new ResourceModel { ResourceId = 1, ResourceName = "Martin Tamer" },
new ResourceModel { ResourceId = 2, ResourceName = "Rose Fuller" },
new ResourceModel { ResourceId = 3, ResourceName = "Margaret Buchanan" },
new ResourceModel { ResourceId = 4, ResourceName = "Fuller King" },
new ResourceModel { ResourceId = 5, ResourceName = "Davolio Fuller" },
new ResourceModel { ResourceId = 6, ResourceName = "Van Jack" }
};
}
public static List<GanttDataSource> GanttData()
{
return new List<GanttDataSource>
{
new GanttDataSource { TaskID = 1, TaskName = "Project Initiation", StartDate = new DateTime(2025, 3, 1), EndDate = new DateTime(2025, 3, 10), Duration = 8, Progress = 100, Resources = new List<int> { 1 } },
new GanttDataSource { TaskID = 2, TaskName = "Requirements Gathering", StartDate = new DateTime(2025, 3, 1), EndDate = new DateTime(2025, 3, 5), Duration = 4, Progress = 100, Resources = new List<int> { 5 }, ParentID = 1 },
new GanttDataSource { TaskID = 3, TaskName = "Feasibility Study", StartDate = new DateTime(2025, 3, 3), EndDate = new DateTime(2025, 3, 7), Duration = 4, Progress = 100, Resources = new List<int> { 2 }, ParentID = 1, Predecessor = "2FS" },
new GanttDataSource { TaskID = 4, TaskName = "Stakeholder Approval", StartDate = new DateTime(2025, 3, 8), EndDate = new DateTime(2025, 3, 8), Duration = 0, Progress = 100, Resources = new List<int> { 3 }, ParentID = 1, Predecessor = "3FS" },

new GanttDataSource { TaskID = 5, TaskName = "Planning Phase", StartDate = new DateTime(2025, 3, 10), EndDate = new DateTime(2025, 3, 20), Duration = 9, Progress = 90, Resources = new List<int> { 1, 5 }, Predecessor = "4FS" },
new GanttDataSource { TaskID = 6, TaskName = "Project Plan Creation", StartDate = new DateTime(2025, 3, 10), EndDate = new DateTime(2025, 3, 14), Duration = 4, Progress = 100, Resources = new List<int> { 6 }, ParentID = 5 },
new GanttDataSource { TaskID = 7, TaskName = "Resource Allocation", StartDate = new DateTime(2025, 3, 12), EndDate = new DateTime(2025, 3, 17), Duration = 5, Progress = 85, Resources = new List<int> { 1, 2 }, ParentID = 5, Predecessor = "6FS" },
new GanttDataSource { TaskID = 8, TaskName = "Risk Assessment", StartDate = new DateTime(2025, 3, 15), EndDate = new DateTime(2025, 3, 19), Duration = 4, Progress = 70, Resources = new List<int> { 1 }, ParentID = 5, Predecessor = "6FS" },

new GanttDataSource { TaskID = 9, TaskName = "Design & Development", StartDate = new DateTime(2025, 3, 20), EndDate = new DateTime(2025, 4, 18), Duration = 28, Progress = 65, Resources = new List<int> { 2, 3 }, Predecessor = "5FS" },
new GanttDataSource { TaskID =10, TaskName = "UI/UX Design", StartDate = new DateTime(2025, 3, 20), EndDate = new DateTime(2025, 3, 28), Duration = 8, Progress = 90, Resources = new List<int> { 4 }, ParentID = 9 },
new GanttDataSource { TaskID =11, TaskName = "Wireframes & Prototypes", StartDate = new DateTime(2025, 3, 20), EndDate = new DateTime(2025, 3, 26), Duration = 6, Progress = 85, Resources = new List<int> { 4 }, ParentID = 10 },
new GanttDataSource { TaskID =12, TaskName = "Backend Development", StartDate = new DateTime(2025, 3, 25), EndDate = new DateTime(2025, 4, 10), Duration = 14, Progress = 60, Resources = new List<int> { 2 }, ParentID = 9, Predecessor = "11FS" },
new GanttDataSource { TaskID =13, TaskName = "API Design", StartDate = new DateTime(2025, 3, 25), EndDate = new DateTime(2025, 3, 29), Duration = 4, Progress = 100, Resources = new List<int> { 2 }, ParentID = 12 },
new GanttDataSource { TaskID =14, TaskName = "Frontend Development", StartDate = new DateTime(2025, 3, 28), EndDate = new DateTime(2025, 4, 12), Duration = 14, Progress = 55, Resources = new List<int> { 3 }, ParentID = 9, Predecessor = "11FS" },

new GanttDataSource { TaskID =15, TaskName = "Testing Phase", StartDate = new DateTime(2025, 4, 10), EndDate = new DateTime(2025, 4, 24), Duration = 12, Progress = 40, Resources = new List<int> { 6 }, Predecessor = "14FS" },
new GanttDataSource { TaskID =16, TaskName = "Unit Testing", StartDate = new DateTime(2025, 4, 10), EndDate = new DateTime(2025, 4, 15), Duration = 5, Progress = 60, Resources = new List<int> { 6 }, ParentID = 15 },
new GanttDataSource { TaskID =17, TaskName = "Integration Testing", StartDate = new DateTime(2025, 4, 16), EndDate = new DateTime(2025, 4, 21), Duration = 5, Progress = 30, Resources = new List<int> { 6 }, ParentID = 15, Predecessor = "16FS" },

new GanttDataSource { TaskID =18, TaskName = "Deployment", StartDate = new DateTime(2025, 4, 24), EndDate = new DateTime(2025, 4, 24), Duration = 0, Progress = 0, Resources = new List<int> { 5 }, Predecessor = "17FS" },
new GanttDataSource { TaskID =19, TaskName = "Project Closure", StartDate = new DateTime(2025, 4, 25), EndDate = new DateTime(2025, 4, 29), Duration = 4, Progress = 0, Resources = new List<int> { 1 }, Predecessor = "18FS" },
new GanttDataSource { TaskID =20, TaskName = "Final Documentation", StartDate = new DateTime(2025, 4, 25), EndDate = new DateTime(2025, 4, 28), Duration = 3, Progress = 0, Resources = new List<int> { 1, 3 }, ParentID = 19 }
};
}

// Updated model classes to support resource allocation
public class GanttDataSource
{
public int TaskID { get; set; }
public string TaskName { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
public int? Duration { get; set; }
public int? Progress { get; set; }
public string Predecessor { get; set; }
public int? ParentID { get; set; }
public List<int> Resources { get; set; } = new List<int>();
}

public class ResourceModel
{
public int ResourceId { get; set; }
public string ResourceName { get; set; }
}
13 changes: 13 additions & 0 deletions ej2-asp-core-mvc/code-snippet/gantt/columns/freezeDirection/razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div id="ganttContainer" style="height:1500px;margin:0;">
@Html.EJS().Gantt("GanttContainer").DataSource((IEnumerable<object>)ViewBag.DataSource).Resources((IEnumerable<object>)ViewBag.Resources).Height("430px").TreeColumnIndex(1).GridLines(Syncfusion.EJ2.Gantt.GridLine.Both).AllowSelection(false).HighlightWeekends(true).SplitterSettings(s => s.Position("65%")).LabelSettings(l => l.TaskLabel("Progress")).TaskFields(tf => { tf.Id("TaskID").Name("TaskName").StartDate("StartDate").EndDate("EndDate").Duration("Duration").Progress("Progress").Dependency("Predecessor").ParentID("ParentID").ResourceInfo("Resources"); }).ResourceFields(rf => { rf.Id("ResourceId").Name("ResourceName"); }).Columns(col =>
{
col.Field("TaskID").HeaderText("Task ID").Width("90").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Freeze("Left").Add();
col.Field("TaskName").HeaderText("Task Name").Width("200").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add();
col.Field("StartDate").HeaderText("Start Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("Duration").HeaderText("Duration").Width("110").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("EndDate").HeaderText("End Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("Progress").HeaderText("Progress").Width("110").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Freeze("Fixed").Add();
col.Field("Predecessor").HeaderText("Dependency").Width("120").Add();
col.Field("Resources").HeaderText("Assignee").Width("150").Freeze("Right").Add();
}).Render()
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@using Syncfusion.EJ2.Gantt

<div>
<ejs-gantt id="GanttContainer"
dataSource="@Model.DataSource"
resources="@Model.Resources"
height="430px"
treeColumnIndex="1"
gridLines="Both"
allowSelection="false"
highlightWeekends="true">
<e-gantt-splitterSettings position="65%"></e-gantt-splitterSettings>
<e-gantt-labelSettings taskLabel="Progress"></e-gantt-labelSettings>
<e-gantt-taskFields id="TaskID" name="TaskName" startDate="StartDate" endDate="EndDate" duration="Duration" progress="Progress" dependency="Predecessor" parentID="ParentID" resourceInfo="Resources"></e-gantt-taskFields>
<e-gantt-resourceFields id="ResourceId" name="ResourceName"></e-gantt-resourceFields>
<e-gantt-columns>
<e-gantt-column field="TaskID" headerText="Task ID" width="90" textAlign="Right" freeze="Left"></e-gantt-column>
<e-gantt-column field="TaskName" headerText="Task Name" width="200" textAlign="Left"></e-gantt-column>
<e-gantt-column field="StartDate" headerText="Start Date" width="130" format="yMd" textAlign="Right"></e-gantt-column>
<e-gantt-column field="Duration" headerText="Duration" width="110" textAlign="Right"></e-gantt-column>
<e-gantt-column field="EndDate" headerText="End Date" width="130" format="yMd" textAlign="Right"></e-gantt-column>
<e-gantt-column field="Progress" headerText="Progress" width="110" textAlign="Center" freeze="Fixed"></e-gantt-column>
<e-gantt-column field="Predecessor" headerText="Dependency" width="120"></e-gantt-column>
<e-gantt-column field="Resources" headerText="Assignee" width="150" freeze="Right"></e-gantt-column>
</e-gantt-columns>
</ejs-gantt>
</div>
Loading