Example of Auto Wrap Column Cells in ASP.NET MVC Tree Grid Control
This sample demonstrates the Tree Grid with the text wrap option enabled for both headers and cell content. This setting ensures that long header text and cell values are fully visible by wrapping onto multiple lines instead of being truncated with an ellipsis.
@* The editor's settings are in the view; the data they read (ViewData) is set in the controller action (see the controller tab). *@
@Html.UiTreeGrid(new UiTreeGridOptions
{
Id = "TreeGrid",
Data = ViewData["datasource"],
AllowTextWrap = true,
AllowFiltering = true,
AllowSorting = true,
ChildMapping = "Subtasks",
TreeColumnIndex = 1,
Height = "400px",
AllowPaging = true,
PageSize = 8,
FilterType = UiGridFilterType.Excel,
Selection = UiGridSelection.Single,
Columns = new List<UiGridColumn>
{
new UiGridColumn { Field = "TaskID", HeaderText = "Task ID", Type = UiColumnType.Number, TextAlign = UiTextAlign.Right },
new UiGridColumn { Field = "TaskName", HeaderText = "Task Name" },
new UiGridColumn { Field = "Description", HeaderText = "Description (Comprehensive Objectives for Deliverables)" },
new UiGridColumn { Field = "EmployeeName", HeaderText = "Assigned To" },
new UiGridColumn { Field = "Priority", HeaderText = "Priority" },
new UiGridColumn { Field = "Status", HeaderText = "Status" },
new UiGridColumn { Field = "StartDate", HeaderText = "Start Date", Type = UiColumnType.Date, TextAlign = UiTextAlign.Right, Format = "M/d/yyyy" },
new UiGridColumn { Field = "EndDate", HeaderText = "End Date", Type = UiColumnType.Date, TextAlign = UiTextAlign.Right, Format = "M/d/yyyy" }
}
})
@Html.UiTreeGrid(new UiTreeGridOptions
{
Id = "TreeGrid",
Data = ViewData["datasource"],
AllowTextWrap = true,
AllowFiltering = true,
AllowSorting = true,
ChildMapping = "Subtasks",
TreeColumnIndex = 1,
Height = "400px",
AllowPaging = true,
PageSize = 8,
FilterType = UiGridFilterType.Excel,
Selection = UiGridSelection.Single,
Columns = new List<UiGridColumn>
{
new UiGridColumn { Field = "TaskID", HeaderText = "Task ID", Type = UiColumnType.Number, TextAlign = UiTextAlign.Right },
new UiGridColumn { Field = "TaskName", HeaderText = "Task Name" },
new UiGridColumn { Field = "Description", HeaderText = "Description (Comprehensive Objectives for Deliverables)" },
new UiGridColumn { Field = "EmployeeName", HeaderText = "Assigned To" },
new UiGridColumn { Field = "Priority", HeaderText = "Priority" },
new UiGridColumn { Field = "Status", HeaderText = "Status" },
new UiGridColumn { Field = "StartDate", HeaderText = "Start Date", Type = UiColumnType.Date, TextAlign = UiTextAlign.Right, Format = "M/d/yyyy" },
new UiGridColumn { Field = "EndDate", HeaderText = "End Date", Type = UiColumnType.Date, TextAlign = UiTextAlign.Right, Format = "M/d/yyyy" }
}
})
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class TreeGridController : Controller
{
// The page is Views/TreeGrid/AutoWrapColumnCells.cshtml; it draws what ViewData holds.
public ActionResult AutoWrapColumnCells()
{
var treeData = WrapTask.GetWrapData();
ViewData["datasource"] = treeData;
return View();
}
public class WrapTask
{
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 Priority { get; set; }
public bool Approved { get; set; }
public string Designation { get; set; }
public int EmployeeID { get; set; }
public string EmployeeName { get; set; }
public string Status { get; set; }
public string Description { get; set; }
public List<WrapTask> Subtasks { get; set; }
public WrapTask() { Subtasks = new List<WrapTask>(); }
public static List<WrapTask> GetWrapData()
{
return new List<WrapTask>
{
new WrapTask
{
TaskID = 1001,
TaskName = "Project Initiation Phase",
StartDate = new DateTime(2025, 1, 6),
EndDate = new DateTime(2025, 1, 17),
Duration = 10,
Progress = 100,
Priority = "High",
Approved = true,
Designation = "Project Manager",
EmployeeID = 5001,
EmployeeName = "Robert King",
Status = "Completed",
Description = "Kickoff meetings and initial project charter approval were completed successfully.",
Subtasks = new List<WrapTask>
{
new WrapTask { TaskID = 1002, TaskName = "Define Project Scope", StartDate = new DateTime(2025,1,6), EndDate = new DateTime(2025,1,8), Duration = 3, Progress = 100, Priority = "Critical", Approved = true, Designation = "Business Analyst", EmployeeID = 5002, EmployeeName = "Nancy Davolio", Status = "Completed", Description = "Documented clear project boundaries and deliverables with full stakeholder agreement." },
new WrapTask { TaskID = 1003, TaskName = "Create Risk Register", StartDate = new DateTime(2025,1,7), EndDate = new DateTime(2025,1,9), Duration = 3, Progress = 100, Priority = "High", Approved = true, Designation = "Risk Manager", EmployeeID = 5003, EmployeeName = "Andrew Fuller", Status = "Completed", Description = "Identified potential risks and defined mitigation strategies early in the project." },
new WrapTask { TaskID = 1004, TaskName = "Team Onboarding Session", StartDate = new DateTime(2025,1,10), EndDate = new DateTime(2025,1,11), Duration = 1, Progress = 100, Priority = "Normal", Approved = true, Designation = "HR Lead", EmployeeID = 5004, EmployeeName = "Janet Leverling", Status = "Completed", Description = "Introduced team members and established communication protocols and collaboration tools." },
new WrapTask { TaskID = 1005, TaskName = "Initiation Phase Sign-off", StartDate = new DateTime(2025,1,17), EndDate = new DateTime(2025,1,17), Duration = 0, Progress = 100, Priority = "Normal", Approved = true, Designation = "Project Sponsor", EmployeeID = 5005, EmployeeName = "Laura Callahan", Status = "Completed", Description = "Obtained official approval to proceed to the planning phase." }
}
},
new WrapTask
{
TaskID = 1006,
TaskName = "Detailed Planning Stage",
StartDate = new DateTime(2025, 1, 20),
EndDate = new DateTime(2025, 2, 7),
Duration = 15,
Progress = 90,
Priority = "High",
Approved = false,
Designation = "Project Manager",
EmployeeID = 5006,
EmployeeName = "Michael Suyama",
Status = "In Progress",
Description = "Comprehensive schedule, resource, and budget planning for the entire project lifecycle.",
Subtasks = new List<WrapTask>
{
new WrapTask { TaskID = 1007, TaskName = "Work Breakdown Structure", StartDate = new DateTime(2025,1,20), EndDate = new DateTime(2025,1,24), Duration = 5, Progress = 100, Priority = "High", Approved = true, Designation = "Planner", EmployeeID = 5007, EmployeeName = "Steven Gray", Status = "Completed", Description = "Broke down the project into manageable tasks and work packages." },
new WrapTask { TaskID = 1008, TaskName = "Estimate Task Durations", StartDate = new DateTime(2025,1,23), EndDate = new DateTime(2025,1,27), Duration = 5, Progress = 100, Priority = "Normal", Approved = true, Designation = "Senior Developer", EmployeeID = 5008, EmployeeName = "Robert King", Status = "Completed", Description = "Used historical data and expert judgment to predict realistic task durations." },
new WrapTask { TaskID = 1009, TaskName = "Assign Resource Roles", StartDate = new DateTime(2025,1,28), EndDate = new DateTime(2025,1,31), Duration = 4, Progress = 100, Priority = "Critical", Approved = true, Designation = "Resource Manager", EmployeeID = 5009, EmployeeName = "Anne Dodsworth", Status = "Completed", Description = "Matched team members’ skills to specific project roles and responsibilities." },
new WrapTask { TaskID = 1010, TaskName = "Build Project Schedule", StartDate = new DateTime(2025,2,3), EndDate = new DateTime(2025,2,7), Duration = 5, Progress = 60, Priority = "High", Approved = false, Designation = "Scheduler", EmployeeID = 5010, EmployeeName = "David William", Status = "In Progress", Description = "Created a detailed Gantt chart with task dependencies, critical path, and milestones." }
}
},
new WrapTask
{
TaskID = 1011,
TaskName = "Design & Architecture Phase",
StartDate = new DateTime(2025, 2, 10),
EndDate = new DateTime(2025, 3, 7),
Duration = 20,
Progress = 75,
Priority = "Critical",
Approved = false,
Designation = "Lead Architect",
EmployeeID = 5011,
EmployeeName = "Margaret Peacock",
Status = "In Progress",
Description = "Created a scalable and secure system architecture meeting performance, reliability, and security requirements.",
Subtasks = new List<WrapTask>
{
new WrapTask { TaskID = 1012, TaskName = "Define System Components", StartDate = new DateTime(2025,2,10), EndDate = new DateTime(2025,2,14), Duration = 5, Progress = 100, Priority = "High", Approved = true, Designation = "Architect", EmployeeID = 5012, EmployeeName = "Steven Buchanan", Status = "Completed", Description = "Identified all required modules, services, and integration points." },
new WrapTask { TaskID = 1013, TaskName = "Design Database Schema", StartDate = new DateTime(2025,2,17), EndDate = new DateTime(2025,2,21), Duration = 5, Progress = 100, Priority = "Critical", Approved = true, Designation = "DBA", EmployeeID = 5013, EmployeeName = "Laura Callahan", Status = "Completed", Description = "Designed a normalized relational database model with optimal indexing strategy." },
new WrapTask { TaskID = 1014, TaskName = "API Design & Review", StartDate = new DateTime(2025,2,24), EndDate = new DateTime(2025,2,28), Duration = 5, Progress = 80, Priority = "High", Approved = false, Designation = "API Lead", EmployeeID = 5014, EmployeeName = "Michael Suyama", Status = "In Progress", Description = "Finalized RESTful API endpoints, contracts, versioning, and authentication methods." },
new WrapTask { TaskID = 1015, TaskName = "UI/UX Wireframes & Mockups", StartDate = new DateTime(2025,2,24), EndDate = new DateTime(2025,3,7), Duration = 10, Progress = 50, Priority = "Normal", Approved = false, Designation = "UX Designer", EmployeeID = 5015, EmployeeName = "Nancy Davolio", Status = "In Progress", Description = "Created high-fidelity wireframes and interactive prototypes for the user interface." }
}
},
new WrapTask
{
TaskID = 1016,
TaskName = "Frontend Development Sprint",
StartDate = new DateTime(2025, 3, 10),
EndDate = new DateTime(2025, 4, 18),
Duration = 30,
Progress = 60,
Priority = "High",
Approved = false,
Designation = "Frontend Lead",
EmployeeID = 5016,
EmployeeName = "Andrew Fuller",
Status = "In Progress",
Description = "Built a responsive and interactive user interface using the React framework.",
Subtasks = new List<WrapTask>
{
new WrapTask { TaskID = 1017, TaskName = "Set Up Project Structure", StartDate = new DateTime(2025,3,10), EndDate = new DateTime(2025,3,12), Duration = 3, Progress = 100, Priority = "Normal", Approved = true, Designation = "DevOps", EmployeeID = 5017, EmployeeName = "Janet Leverling", Status = "Completed", Description = "Initialized the repository with proper folder structure and tooling." },
new WrapTask { TaskID = 1018, TaskName = "Create Login Page", StartDate = new DateTime(2025,3,13), EndDate = new DateTime(2025,3,18), Duration = 6, Progress = 100, Priority = "High", Approved = true, Designation = "Frontend Dev", EmployeeID = 5018, EmployeeName = "Robert King", Status = "Completed", Description = "Implemented secure login with form validation, OAuth, and password recovery." },
new WrapTask { TaskID = 1019, TaskName = "Build Dashboard View", StartDate = new DateTime(2025,3,19), EndDate = new DateTime(2025,3,28), Duration = 8, Progress = 90, Priority = "Critical", Approved = false, Designation = "Senior Developer", EmployeeID = 5019, EmployeeName = "Anne Dodsworth", Status = "In Progress", Description = "Developed the main dashboard with real-time data visualization widgets." },
new WrapTask { TaskID = 1020, TaskName = "Implement Navigation Menu", StartDate = new DateTime(2025,3,31), EndDate = new DateTime(2025,4,4), Duration = 5, Progress = 70, Priority = "Normal", Approved = false, Designation = "Frontend Dev", EmployeeID = 5020, EmployeeName = "David William", Status = "In Progress", Description = "Created a responsive sidebar and top navigation system with role-based access." },
new WrapTask { TaskID = 1021, TaskName = "Add Form Components", StartDate = new DateTime(2025,4,7), EndDate = new DateTime(2025,4,18), Duration = 10, Progress = 30, Priority = "High", Approved = false, Designation = "UI Engineer", EmployeeID = 5021, EmployeeName = "Margaret Peacock", Status = "In Progress", Description = "Built reusable form components with validation, accessibility, and theming support." }
}
},
new WrapTask
{
TaskID = 1022,
TaskName = "Backend Services Development",
StartDate = new DateTime(2025, 3, 10),
EndDate = new DateTime(2025, 4, 25),
Duration = 35,
Progress = 55,
Priority = "Critical",
Approved = false,
Designation = "Backend Lead",
EmployeeID = 5022,
EmployeeName = "Steven Gray",
Status = "In Progress",
Description = "Developed secure and scalable REST APIs using Node.js and Express.",
Subtasks = new List<WrapTask>
{
new WrapTask { TaskID = 1023, TaskName = "Set Up Server Environment", StartDate = new DateTime(2025,3,10), EndDate = new DateTime(2025,3,14), Duration = 5, Progress = 100, Priority = "Normal", Approved = true, Designation = "DevOps Engineer", EmployeeID = 5023, EmployeeName = "Laura Callahan", Status = "Completed", Description = "Configured Node.js server with clustering, PM2, and logging." },
new WrapTask { TaskID = 1024, TaskName = "User Authentication Service", StartDate = new DateTime(2025,3,17), EndDate = new DateTime(2025,3,25), Duration = 7, Progress = 100, Priority = "Critical", Approved = true, Designation = "Backend Dev", EmployeeID = 5024, EmployeeName = "Michael Suyama", Status = "Completed", Description = "Implemented JWT-based authentication with refresh tokens and password hashing." },
new WrapTask { TaskID = 1025, TaskName = "Product Management API", StartDate = new DateTime(2025,3,26), EndDate = new DateTime(2025,4,5), Duration = 9, Progress = 80, Priority = "High", Approved = false, Designation = "API Developer", EmployeeID = 5025, EmployeeName = "Nancy Davolio", Status = "In Progress", Description = "Created CRUD endpoints for product catalog management with filtering and pagination." },
new WrapTask { TaskID = 1026, TaskName = "Order Processing Service", StartDate = new DateTime(2025,4,7), EndDate = new DateTime(2025,4,18), Duration = 10, Progress = 40, Priority = "High", Approved = false, Designation = "Backend Dev", EmployeeID = 5026, EmployeeName = "Andrew Fuller", Status = "In Progress", Description = "Built order creation, payment integration, and fulfillment workflows." },
new WrapTask { TaskID = 1027, TaskName = "Reporting & Analytics API", StartDate = new DateTime(2025,4,14), EndDate = new DateTime(2025,4,25), Duration = 10, Progress = 10, Priority = "Normal", Approved = false, Designation = "Data Engineer", EmployeeID = 5027, EmployeeName = "Janet Leverling", Status = "In Progress", Description = "Developed endpoints for sales, performance, and business intelligence analytics." }
}
},
new WrapTask
{
TaskID = 1028,
TaskName = "Testing & Quality Assurance",
StartDate = new DateTime(2025, 4, 21),
EndDate = new DateTime(2025, 5, 16),
Duration = 20,
Progress = 20,
Priority = "High",
Approved = false,
Designation = "QA Lead",
EmployeeID = 5028,
EmployeeName = "Anne Dodsworth",
Status = "In Progress",
Description = "Conducted comprehensive testing including unit, integration, performance, security, and user acceptance testing.",
Subtasks = new List<WrapTask>
{
new WrapTask { TaskID = 1029, TaskName = "Write Unit Tests", StartDate = new DateTime(2025,4,21), EndDate = new DateTime(2025,4,30), Duration = 8, Progress = 60, Priority = "Normal", Approved = false, Designation = "QA Engineer", EmployeeID = 5029, EmployeeName = "David William", Status = "In Progress", Description = "Achieved 90% code coverage across all modules using Jest and PyTest." },
new WrapTask { TaskID = 1030, TaskName = "Integration Testing Phase", StartDate = new DateTime(2025,5,1), EndDate = new DateTime(2025,5,9), Duration = 7, Progress = 0, Priority = "High", Approved = false, Designation = "Test Lead", EmployeeID = 5030, EmployeeName = "Margaret Peacock", Status = "Not Started", Description = "Verified seamless communication between frontend, backend, and third-party services." },
new WrapTask { TaskID = 1031, TaskName = "Performance & Load Testing", StartDate = new DateTime(2025,5,5), EndDate = new DateTime(2025,5,12), Duration = 6, Progress = 0, Priority = "Critical", Approved = false, Designation = "Performance Tester", EmployeeID = 5031, EmployeeName = "Steven Gray", Status = "Not Started", Description = "Simulated 10,000 concurrent users using JMeter and Gatling." },
new WrapTask { TaskID = 1032, TaskName = "Security & Vulnerability Scan", StartDate = new DateTime(2025,5,6), EndDate = new DateTime(2025,5,12), Duration = 5, Progress = 0, Priority = "Critical", Approved = false, Designation = "Security Analyst", EmployeeID = 5032, EmployeeName = "Laura Callahan", Status = "Not Started", Description = "Performed OWASP ZAP scans and manual penetration testing." },
new WrapTask { TaskID = 1033, TaskName = "User Acceptance Testing (UAT)", StartDate = new DateTime(2025,5,12), EndDate = new DateTime(2025,5,16), Duration = 5, Progress = 0, Priority = "High", Approved = false, Designation = "UAT Coordinator", EmployeeID = 5033, EmployeeName = "Robert King", Status = "Not Started", Description = "Conducted final validation with actual end users and stakeholders." }
}
},
new WrapTask
{
TaskID = 1034,
TaskName = "Deployment & Go-Live",
StartDate = new DateTime(2025, 5, 19),
EndDate = new DateTime(2025, 5, 30),
Duration = 10,
Progress = 0,
Priority = "Critical",
Approved = false,
Designation = "Release Manager",
EmployeeID = 5034,
EmployeeName = "Michael Suyama",
Status = "Not Started",
Description = "Executed final production deployment using a zero-downtime blue-green strategy.",
Subtasks = new List<WrapTask>
{
new WrapTask { TaskID = 1035, TaskName = "Prepare Production Servers", StartDate = new DateTime(2025,5,19), EndDate = new DateTime(2025,5,21), Duration = 3, Progress = 0, Priority = "High", Approved = false, Designation = "SysAdmin", EmployeeID = 5035, EmployeeName = "Nancy Davolio", Status = "Not Started", Description = "Configured load balancers, SSL certificates, and monitoring tools." },
new WrapTask { TaskID = 1036, TaskName = "Database Migration", StartDate = new DateTime(2025,5,22), EndDate = new DateTime(2025,5,23), Duration = 2, Progress = 0, Priority = "Critical", Approved = false, Designation = "DBA", EmployeeID = 5036, EmployeeName = "Andrew Fuller", Status = "Not Started", Description = "Executed final schema updates and data migration scripts." },
new WrapTask { TaskID = 1037, TaskName = "Blue-Green Deployment", StartDate = new DateTime(2025,5,26), EndDate = new DateTime(2025,5,27), Duration = 2, Progress = 0, Priority = "Critical", Approved = false, Designation = "DevOps Lead", EmployeeID = 5037, EmployeeName = "Janet Leverling", Status = "Not Started", Description = "Switched live traffic from old to new version with zero downtime." },
new WrapTask { TaskID = 1038, TaskName = "Post-Deployment Validation", StartDate = new DateTime(2025,5,28), EndDate = new DateTime(2025,5,30), Duration = 3, Progress = 0, Priority = "High", Approved = false, Designation = "QA Lead", EmployeeID = 5038, EmployeeName = "Anne Dodsworth", Status = "Not Started", Description = "Ran smoke tests and verified all critical features in production." },
new WrapTask { TaskID = 1039, TaskName = "Project Closure & Celebration", StartDate = new DateTime(2025,5,30), EndDate = new DateTime(2025,5,30), Duration = 1, Progress = 0, Priority = "Normal", Approved = false, Designation = "Project Manager", EmployeeID = 5039, EmployeeName = "Robert King", Status = "Not Started", Description = "Held project closure ceremony, lessons learned session, and team recognition event." }
}
}
};
}
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
In this demo, the "Title" and "Description" columns exceeds the available width, so its header and cell content are wrapped across multiple lines for better readability. Text wrapping is enabled by setting the Tree Grid's allowTextWrap property to true, which automatically applies wrapping to both header and cell content.