# gantt-default

> Gantt chart displays local project tasks with filtering, sorting, resizing, and a view selector.

**Framework:** aspnet-mvc  **Component:** Gantt  **Variant:** default

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/aspnet-mvc/gantt-default.json
```

**Install Package(s)**

```bash
Install-Package Syncfusion.AspNetMvc.Gantt
Install-Package Syncfusion.AspNetMvc.DropDowns
Install-Package Syncfusion.AspNetMvc.Grid
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/gantt-default/Gantt.cshtml

```cshtml
@using Syncfusion.EJ2
@using Syncfusion.EJ2.DropDowns
@{
    ViewData["Title"] = "OverView";
}

@section ControlsSection{
    @{
        List<object> toolbarItems = new List<object> { "ExpandAll", "CollapseAll" };
        toolbarItems.Add(new
        {
            type = "Input",
            align = "Right",
            template = "#ToolbarTemplate"
        });
    }
    <div id="ToolbarTemplate">
        <div>
            @(Html.EJS().DropDownList("Drop").DataSource((IEnumerable<object>)ViewData["Data"])
                .Fields(new DropDownListFieldSettings { Text = "type", Value = "id" }).Placeholder("View").Width("99px").Change("Change")
                .Render()
            )
        </div>
    </div>
    <div class="control-section">
        <div class="content-wrapper">
            @(Html.EJS().Gantt("OverView").DataSource((IEnumerable<object>)ViewData["DataSource"]).Height("500px").AllowFiltering(true)
                .HighlightWeekends(true).AllowSelection(true).AllowResizing(true).TreeColumnIndex(1)
                .DateFormat("MMM dd, y").Toolbar(toolbarItems).Load("load").AllowSorting(true).ShowColumnMenu(true)
                .TaskFields(ts => ts.Id("TaskId").Name("TaskName").StartDate("StartDate").EndDate("EndDate").Duration("TimeLog").Progress("Progress")
                .Dependency("Predecessor").ParentID("ParentID").ResourceInfo("Assignee"))
                .Resources((IEnumerable<object>)ViewData["Resources"])
                .ResourceFields(rf => rf.Id("ResourceId").Name("ResourceName").Unit("ResourceUnit"))
                .TaskbarHeight(24).RowHeight(36)
                .Columns(col =>
                {
                    col.Field("TaskId").Width(80).Visible(false).Add();
                    col.Field("TaskName").HeaderText("Product Release").Width(200).Add();
                    col.Field("Assignee").HeaderText("Assignee").Width(130).Template("#columnTemplate").Add();
                    col.Field("Status").HeaderText("Status").Width(120).MinWidth(100).Template("#columnTemplate1").Add();
                    col.Field("Priority").HeaderText("Priority").Width(100).MinWidth(80).Template("#columnTemplate2").Add();
                    col.Field("Work").HeaderText("Planned Hours").Width(120).Add();
                    col.Field("TimeLog").HeaderText("Work Log").Width(120).Add();
                })
                .SplitterSettings(sp => sp.Position("55.5%"))
                .EventMarkers(em =>
                {
                    em.Day("04/04/2024").Label("Q-1 Release").Add();
                    em.Day("06/30/2024").Label("Q-2 Release").Add();
                    em.Day("09/29/2024").Label("Q-3 Release").Add();
                })
                .Holidays(hol => {
                    hol.From("01/01/2024").To("01/01/2024").Label("New Year holiday").Add();
                    hol.From("12/25/2023").To("12/26/2023").Label("Christmas holidays").Add();
                })
                .SelectionSettings(ss => ss.Mode(Syncfusion.EJ2.Grids.SelectionMode.Row).Type(Syncfusion.EJ2.Grids.SelectionType.Single).EnableToggle(true))
                .LabelSettings(ls => ls.RightLabel("Assignee").TaskLabel("${Progress}%"))
                .TimelineSettings(ts => ts.TimelineUnitSize(50).ShowTooltip(true).TopTier(tt => tt.Format("MMM yyyy").Unit(Syncfusion.EJ2.Gantt.TimelineViewMode.Month))
                .BottomTier(bt => bt.Format("dd").Count(4).Unit(Syncfusion.EJ2.Gantt.TimelineViewMode.Day)))
                .FilterSettings(f => f.Type(Syncfusion.EJ2.Gantt.FilterType.Menu))
                .GridLines(Syncfusion.EJ2.Gantt.GridLine.Vertical)
                .ProjectStartDate("12/24/2023")
                .ProjectEndDate("10/26/2024")
                .Render()
            )
        </div>
    </div>

    <script id="columnTemplate" type="text/x-template">
        ${if(ganttProperties.resourceNames)}
        <div class="image">
            <img src="../Content/gantt/images/${ganttProperties.resourceNames}.png" style="height:25px;width:25px" />
            <div style="display:inline-block;width:100%;position:relative;${isRtl()}">${ganttProperties.resourceNames}</div>
        </div>
        ${/if}
    </script>
    <script type="text/x-template" id="columnTemplate1">
        ${if(taskData.Status)}
        <div style="${Status(taskData.Status)}"><span style="${StatusContent(taskData.Status)}">${taskData.Status}</span></div>
        ${/if}
    </script>
    <script type="text/x-template" id="columnTemplate2">
        ${if(taskData.Priority)}
        <div style="${Priority(taskData.Priority)}"><span style="${PriorityContent(taskData.Priority)}">${taskData.Priority}</span></div>
        ${/if}
    </script>

    <style>
        .e-gantt-child-taskbar,
        .e-gantt-parent-taskbar {
            border-radius: 10px !important
        }
        .fluent2 #overviewSample .e-toolbar-items .e-toolbar-right .e-template .e-input-group,
        .fluent2-dark #overviewSample .e-toolbar-items .e-toolbar-right .e-template .e-input-group,
        .fluent2-highcontrast #overviewSample .e-toolbar-items .e-toolbar-right .e-template .e-input-group {
            width: 99px !important;
        }
         .e-bigger.fluent2 .e-toolbar-items .e-toolbar-right .e-template .e-input-group,
        .e-bigger.fluent2-dark .e-toolbar-items .e-toolbar-right .e-template .e-input-group,
        .e-bigger.fluent2-highcontrast .e-toolbar-items .e-toolbar-right .e-template .e-input-group,
        .e-bigger.bootstrap5 .e-toolbar-items .e-toolbar-right .e-template .e-input-group,
        .e-bigger.bootstrap5\.3 .e-toolbar-items .e-toolbar-right .e-template .e-input-group,
        .e-bigger.bootstrap5\.3-dark-lite .e-toolbar-items .e-toolbar-right .e-template .e-input-group,
        .e-bigger.bootstrap5\.3-dark .e-toolbar-items .e-toolbar-right .e-template .e-input-group, 
        .e-bigger.bootstrap5\.3-lite .e-toolbar-items .e-toolbar-right .e-template .e-input-group {
            width: 101px !important;
        }
    </style>

    <script>
        var theme;
        var style;
        var currentTheme;
        var statusStyleColor;
        var priorityStyle;
        var priorityContentStyle;
        var statusContentstyleColor;
        function load() {
            var themeCollection = ['bootstrap5', 'bootstrap', 'bootstrap4', 'fluent', 'fabric', 'fusionnew', 'material3', 'material', 'highcontrast', 'tailwind', 'fluent2', 'tailwind3', 'bootstrap5.3'];
            theme = window.themeName;
            var check = themeCollection.indexOf(theme);
            if (check >= 0) {
                currentTheme = true;
            }
            else {
                currentTheme = false;
            }
        }
        function isRtl() {
            let gantt = document.getElementsByClassName('e-gantt')[0].ej2_instances[0];
            if (gantt.enableRtl) {
                return 'right:10px;';
            } else {
                return 'left:10px;';
            }
        }

        function Status(status) {
            switch (status) {
                case "In Progress":
                    statusStyleColor = (currentTheme) ? "#DFECFF" : "#2D3E57";
                    style = "display: flex; padding: 0px 12px; gap: 10px; width: 96px; height: 24px; border-radius: 24px; background:" + statusStyleColor;
                    break;
                case "Open":
                    style = "background-color: red; color: white; border-radius: 15px; padding:6px";
                    break;
                case "On Hold":
                    statusStyleColor = (currentTheme) ? "#E4E4E7" : "#3C3B43";
                    style = "display: flex; border-radius: 24px; padding: 0px 12px; gap: 10px; width: 78px; height: 24px; background:" + statusStyleColor;
                    break;
                case "Completed":
                    statusStyleColor = (currentTheme) ? "#DFFFE2" : "#16501C";
                    style = "display: flex; padding: 0px 12px; gap: 10px; width: 98px; height: 24px; border-radius: 24px;background:" + statusStyleColor;
                    break;
                case "High":
                    statusStyleColor = (currentTheme) ? "#FFEBE9" : "#48211D";
                    style = "display: flex; padding: 0px 12px; gap: 10px; width: 55px; height: 24px; border-radius: 24px; background:" + statusStyleColor;
                    break;
            }
            return style;
        }

        function StatusContent(status) {
            switch (status) {
                case "In Progress":
                    statusContentstyleColor = (currentTheme) ? "#006AA6" : "#34B6FF";
                    style = "width: 72px; height: 22px; font-style: normal; font-weight: 500; font-size: 14px; line-height: 20px; text-align: center; color: " + statusContentstyleColor;
                    break;
                case "Open":
                    style = "background-color: red; color: white; border-radius: 15px; padding:6px";
                    break;
                case "On Hold":
                    statusContentstyleColor = (currentTheme) ? "#766B7C" : "#CDCBD7";
                    style = "width: 54px; height: 22px; font-style: normal; font-weight: 500; font-size: 14px; line-height: 20px; text-align: center; color: " + statusContentstyleColor;
                    break;
                case "Completed":
                    statusContentstyleColor = (currentTheme) ? "#00A653" : "#92FFC8";
                    style = "width: 74px; height: 22px; font-style: normal; font-weight: 500; font-size: 14px; line-height: 20px; text-align: center; color: " + statusContentstyleColor;
                    break;
                case "High":
                    statusContentstyleColor = (currentTheme) ? "#FF3740" : "#FFB5B8";
                    style = "width: 31px; height: 22px; font-style: normal; font-weight: 500; font-size: 14px; line-height: 20px; text-align: center; color: " + statusContentstyleColor;
                    break;
            }
            return style;
        }

        function Priority(priority) {
            switch (priority) {
                case "Low":
                    priorityStyle = (currentTheme) ? "#FFF6D1" : "#473F1E";
                    style = "display: flex; padding: 0px 12px; gap: 10px; width: 52px; height: 24px; border-radius: 24px; background: " + priorityStyle;
                    break;
                case "Normal":
                    priorityStyle = (currentTheme) ? "#F5DFFF" : "#4D2F5A";
                    style = "display: flex; padding: 0px 12px; gap: 10px; width: 73px; height: 24px; border-radius: 24px; background: " + priorityStyle;
                    break;
                case "Critical":
                    priorityStyle = (currentTheme) ? "#FFEBE9" : "#48211D";
                    style = "display: flex; padding: 0px 12px; gap: 10px; width: 72px; height: 24px; border-radius: 24px; background: " + priorityStyle;
                    break;
                case "High":
                    priorityStyle = (currentTheme) ? "#FFEBE9" : "#48211D";
                    style = "display: flex; padding: 0px 12px; gap: 10px; width: 55px; height: 24px; border-radius: 24px; background: " + priorityStyle;
                    break;
            }
            return style;
        }

        function PriorityContent(priority) {
            switch (priority) {
                case "Low":
                    priorityContentStyle = (currentTheme) ? "#70722B" : "#FDFF88";
                    style = "width: 28px; height: 22px; font-style: normal; font-weight: 500; font-size: 14px; line-height: 20px; text-align: center; color: " + priorityContentStyle;
                    break;
                case "Normal":
                    priorityContentStyle = (currentTheme) ? "#7100A6" : "#E3A9FF";
                    style = "width: 49px; height: 22px; font-style: normal; font-weight: 500; font-size: 14px; line-height: 20px; text-align: center; color: " + priorityContentStyle;
                    break;
                case "Critical":
                    priorityContentStyle = (currentTheme) ? "#FF3740" : "#FFB5B8";
                    style = "width: 48px; height: 22px; font-style: normal; font-weight: 500; font-size: 14px; line-height: 20px; text-align: center; color: " + priorityContentStyle;
                    break;
                case "High":
                    priorityContentStyle = (currentTheme) ? "#FF3740" : "#FFB5B8";
                    style = "width: 31px; height: 22px; font-style: normal; font-weight: 500; font-size: 14px; line-height: 20px; text-align: center; color: " + priorityContentStyle;
                    break;
            }
            return style;
        }

        function Change(e) {
            var ganttObj = document.getElementById("OverView").ej2_instances[0];
            var position = e.value;
            if (position === 'Grid') {
                ganttObj.splitterSettings.position = '100%';
            }
            else if (position === 'Gantt') {
                ganttObj.splitterSettings.position = '0%';
            }
            else {
                ganttObj.splitterSettings.position = '55.5%';
            }
        }
    </script>
}
```

### src/components/gantt-default/GanttController.cs

```cs
using EJ2MVCSampleBrowser.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using static EJ2MVCSampleBrowser.Models.GanttData;

namespace EJ2MVCSampleBrowser.Models
{
    public class GanttResources
    {
        public int ResourceId;
        public string ResourceName;
        public int ResourceUnit;
    }

    public class GanttTaskData
    {
        public int TaskId;
        public string TaskName;
        public string StartDate;
        public string EndDate;
        public int TimeLog;
        public int Progress;
        public string Predecessor;
        public int ParentID;
        public int[] Assignee;
        public string Status;
        public string Priority;
        public int Work;
    }

    public class GanttResourceData
    {
        public int ResourceId;
        public string ResourceName;
        public int ResourceUnit;
        public string ResourceGroup;
    }

    public static class GanttData
    {
        public static List<GanttTaskData> OverviewData()
        {
            return new List<GanttTaskData>
            {
                new GanttTaskData { TaskId = 1,  TaskName = "Product Release",       StartDate = "2023-12-25", EndDate = "2024-10-26", TimeLog = 1700, Progress = 50,  Predecessor = "",  ParentID = 0, Assignee = new int[] { 1 }, Status = "In Progress", Priority = "High",     Work = 170 },
                new GanttTaskData { TaskId = 2,  TaskName = "Requirement Planning",  StartDate = "2023-12-25", EndDate = "2024-01-31", TimeLog = 250,  Progress = 100, Predecessor = "",  ParentID = 1, Assignee = new int[] { 1 }, Status = "Completed",   Priority = "High",     Work = 250 },
                new GanttTaskData { TaskId = 3,  TaskName = "Design Phase",          StartDate = "2024-02-01", EndDate = "2024-03-15", TimeLog = 300,  Progress = 90,  Predecessor = "2", ParentID = 1, Assignee = new int[] { 2 }, Status = "In Progress", Priority = "High",     Work = 300 },
                new GanttTaskData { TaskId = 4,  TaskName = "Implementation",        StartDate = "2024-03-16", EndDate = "2024-06-30", TimeLog = 700,  Progress = 60,  Predecessor = "3", ParentID = 1, Assignee = new int[] { 3 }, Status = "In Progress", Priority = "Critical", Work = 700 },
                new GanttTaskData { TaskId = 5,  TaskName = "Testing",               StartDate = "2024-07-01", EndDate = "2024-08-31", TimeLog = 250,  Progress = 30,  Predecessor = "4", ParentID = 1, Assignee = new int[] { 4 }, Status = "Open",       Priority = "Medium",   Work = 250 },
                new GanttTaskData { TaskId = 6,  TaskName = "Deployment",            StartDate = "2024-09-01", EndDate = "2024-10-26", TimeLog = 200,  Progress = 0,   Predecessor = "5", ParentID = 1, Assignee = new int[] { 5 }, Status = "Open",       Priority = "High",     Work = 200 },
                new GanttTaskData { TaskId = 7,  TaskName = "Q-1 Release",           StartDate = "2024-04-04", EndDate = "2024-04-04", TimeLog = 0,    Progress = 100, Predecessor = "4", ParentID = 1, Assignee = new int[] { 1 }, Status = "Milestone", Priority = "Critical", Work = 0   },
                new GanttTaskData { TaskId = 8,  TaskName = "Q-2 Release",           StartDate = "2024-06-30", EndDate = "2024-06-30", TimeLog = 0,    Progress = 100, Predecessor = "4", ParentID = 1, Assignee = new int[] { 1 }, Status = "Milestone", Priority = "Critical", Work = 0   },
                new GanttTaskData { TaskId = 9,  TaskName = "Q-3 Release",           StartDate = "2024-09-29", EndDate = "2024-09-29", TimeLog = 0,    Progress = 0,   Predecessor = "5", ParentID = 1, Assignee = new int[] { 1 }, Status = "Milestone", Priority = "Critical", Work = 0   },
                new GanttTaskData { TaskId = 10, TaskName = "Post-release Support",  StartDate = "2024-10-15", EndDate = "2024-10-26", TimeLog = 80,   Progress = 0,   Predecessor = "6", ParentID = 1, Assignee = new int[] { 2 }, Status = "Open",       Priority = "Low",      Work = 80  }
            };
        }

        public static List<GanttTaskData> DefaultEditingData()
        {
            return OverviewData();
        }

        public static List<GanttTaskData> EditingData()
        {
            return OverviewData();
        }

        public static List<GanttTaskData> ProjectNewData()
        {
            return OverviewData();
        }

        public static List<GanttTaskData> ResourceViewData()
        {
            return OverviewData();
        }

        public static List<GanttResources> EditingResources()
        {
            return new List<GanttResources>
            {
                new GanttResources { ResourceId = 1, ResourceName = "Martin Tamer",  ResourceUnit = 100 },
                new GanttResources { ResourceId = 2, ResourceName = "Rose Fuller",   ResourceUnit = 100 },
                new GanttResources { ResourceId = 3, ResourceName = "Margaret Buchanan", ResourceUnit = 100 },
                new GanttResources { ResourceId = 4, ResourceName = "Fuller King",   ResourceUnit = 100 },
                new GanttResources { ResourceId = 5, ResourceName = "Davolio Fuller", ResourceUnit = 100 }
            };
        }

        public static List<GanttResourceData> GetResourceGroup()
        {
            return new List<GanttResourceData>
            {
                new GanttResourceData { ResourceId = 1, ResourceName = "Martin Tamer",    ResourceUnit = 100, ResourceGroup = "Team A" },
                new GanttResourceData { ResourceId = 2, ResourceName = "Rose Fuller",     ResourceUnit = 100, ResourceGroup = "Team A" },
                new GanttResourceData { ResourceId = 3, ResourceName = "Margaret Buchanan", ResourceUnit = 100, ResourceGroup = "Team B" },
                new GanttResourceData { ResourceId = 4, ResourceName = "Fuller King",     ResourceUnit = 100, ResourceGroup = "Team B" },
                new GanttResourceData { ResourceId = 5, ResourceName = "Davolio Fuller",  ResourceUnit = 100, ResourceGroup = "Team C" }
            };
        }
    }
}

namespace EJ2MVCSampleBrowser.Controllers.Gantt
{

    public partial class GanttChartController : Controller
    {
        // GET: Gantt
        public ActionResult OverView()
        {
            ViewData["DataSource"] = GanttData.OverviewData();
            ViewData["Resources"] = this.GetResources();
            ViewData["Data"] = GanttDropDownLists.GridLinesData();
            return View("~/Views/Home/gantt/default/Gantt.cshtml");
        }
        public List<GanttResources> GetResources()
        {
            return GanttData.EditingResources();
        }
        public class GanttDropDownLists
        {
            public string id { get; set; }
            public string type { get; set; }

            public static List<GanttDropDownLists> GridLinesData()
            {
                List<GanttDropDownLists> Data = new List<GanttDropDownLists>();
                Data.Add(new GanttDropDownLists { id = "Default", type = "Default" });
                Data.Add(new GanttDropDownLists { id = "Grid", type = "Grid" });
                Data.Add(new GanttDropDownLists { id = "Gantt", type = "Gantt" });
                return Data;
            }
        }
    }
}
```
