Syncfusion.AspNetMvc.TreeGrid
34.1.30
Prefix Reserved
dotnet add package Syncfusion.AspNetMvc.TreeGrid --version 34.1.30
NuGet\Install-Package Syncfusion.AspNetMvc.TreeGrid -Version 34.1.30
<PackageReference Include="Syncfusion.AspNetMvc.TreeGrid" Version="34.1.30" />
<PackageVersion Include="Syncfusion.AspNetMvc.TreeGrid" Version="34.1.30" />
<PackageReference Include="Syncfusion.AspNetMvc.TreeGrid" />
paket add Syncfusion.AspNetMvc.TreeGrid --version 34.1.30
#r "nuget: Syncfusion.AspNetMvc.TreeGrid, 34.1.30"
#:package Syncfusion.AspNetMvc.TreeGrid@34.1.30
#addin nuget:?package=Syncfusion.AspNetMvc.TreeGrid&version=34.1.30
#tool nuget:?package=Syncfusion.AspNetMvc.TreeGrid&version=34.1.30
Syncfusion® ASP.NET MVC TreeGrid Component
Displays hierarchical (parent-child) data in a grid layout with expand/collapse capability, combining DataGrid features with tree visualization.
Key Features
- Hierarchical Data Display: Renders hierarchical data with expandable/collapsible rows for parent-child relationships
- Multiple Data Models: Supports self-referential and nested data models for flexible hierarchy representation
- Data Operations: Sorting, filtering, and searching across hierarchical data with multi-level support
- Editing Capabilities: Inline, dialog, and batch editing modes for updating hierarchical data
- Column Management: Column resizing, reordering, freezing, hiding, and auto-sizing
- Performance: Virtual scrolling for efficiently handling large tree datasets
- Aggregations: Summary rows at parent and child levels for data aggregation
- Export Support: Export to Excel, CSV, and PDF formats
- Accessibility: Full keyboard navigation and screen reader support
Common Setup
These setup steps are required only once for your application, regardless of which Syncfusion components you use.
1. Install Base NuGet Package
Install-Package Syncfusion.AspNetMvc.TreeGrid
2. Add Namespace Reference
Edit Web.config under the Views folder and add the Syncfusion.EJ2 namespace:
<namespaces>
<add namespace="Syncfusion.EJ2"/>
</namespaces>
3. Add Stylesheet & Script References
In your layout file (~/Views/Shared/_Layout.cshtml), add the following in the <head> section:
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewBag.Title - Syncfusion Application</title>
<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/34.1.30/fluent2.css" />
<script src="https://cdn.syncfusion.com/ej2/34.1.30/dist/ej2.min.js"></script>
</head>
4. Register Script Manager
At the end of the <body> tag in your layout file (~/Views/Shared/_Layout.cshtml):
<body>
@RenderBody()
@Html.EJS().ScriptManager()
</body>
Quick Start
Step 1: Add ASP.NET MVC TreeGrid control
Add the Syncfusion® ASP.NET MVC TreeGrid control ~/Views/Home/Index.cshtml page:
@Html.EJS().TreeGrid("TreeGrid").DataSource((IEnumerable<object>)ViewBag.DataSource).Columns(col =>
{
col.Field("TaskId").HeaderText("Task ID").Width(70).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("TaskName").HeaderText("Task Name").Width(160).Add();
col.Field("StartDate").HeaderText("Start Date").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width(90).Add();
col.Field("EndDate").HeaderText("End Date").Width(90).Format("yMd").Add();
col.Field("Duration").HeaderText("Duration").Width(80).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
}).ChildMapping("Children").TreeColumnIndex(1).Render()
Step 2: Create controller ~/Controllers/HomeController.cs
public class HomeController : Controller
{
public ActionResult Index()
{
List<Task> task = new List<Task>();
Task parent1 = new Task { TaskID = 1, TaskName = "Planning", StartDate = new DateTime(2025, 2, 4), EndDate = new DateTime(2025, 2, 7), Duration = 4, Children = new List<Task>() };
parent1.Children.Add(new Task(2, "Plan timeline", new DateTime(2025, 2, 4), new DateTime(2025, 2, 7), 4));
parent1.Children.Add(new Task(3, "Plan budget", new DateTime(2025, 2, 4), new DateTime(2025, 2, 7), 4));
Task parent2 = new Task { TaskID = 4, TaskName = "Design", StartDate = new DateTime(2025, 2, 10), EndDate = new DateTime(2025, 2, 14), Duration = 5, Children = new List<Task>() };
parent2.Children.Add(new Task(5, "Software Specification", new DateTime(2025, 2, 10), new DateTime(2025, 2, 12), 3));
parent2.Children.Add(new Task(6, "Design Documentation", new DateTime(2025, 2, 13), new DateTime(2025, 2, 14), 2));
parent2.Children.Add(new Task(7, "Design complete", new DateTime(2025, 2, 14), new DateTime(2025, 2, 14), 1));
task.Add(parent1);
task.Add(parent2);
ViewBag.DataSource = task;
return View();
}
public class Task
{
public Task() { }
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 List<Task> Children { get; set; }
public Task(int taskID, string taskName, DateTime start, DateTime end, int duration)
{
this.TaskID = taskID;
this.TaskName = taskName;
this.StartDate = start;
this.EndDate = end;
this.Duration = duration;
}
}
}
Run the Application
Press Ctrl+F5 to run the application in your browser.
Documentation
Support
License
This is a commercial product and requires a paid license for possession or use. Review the Syncfusion® EULA
About Syncfusion®
Syncfusion® provides 1600+ UI components and frameworks for web, mobile, and desktop development across multiple platforms:
Web: Blazor | ASP.NET MVC | ASP.NET MVC | JavaScript | Angular | React | Vue
Desktop: WinForms | WPF | WinUI
Learn more at www.syncfusion.com
sales@syncfusion.com | Toll Free: 1-888-9-DOTNET
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
- Newtonsoft.Json (>= 13.0.3)
- Syncfusion.AspNetMvc.Base (>= 34.1.30)
- Syncfusion.AspNetMvc.Grid (>= 34.1.30)
- Syncfusion.EJ2.JavaScript (>= 34.1.30)
- Syncfusion.Licensing (>= 34.1.30)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.