@* 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 = "StackedHeader",
Data = ViewData["datasource"],
ChildMapping = "Children",
TreeColumnIndex = 1,
Height = "350px",
AllowPaging = true,
PageCount = 5,
Toolbar = new List<string> { "ColumnChooser" },
Selection = UiGridSelection.Single,
Columns = new List<UiGridColumn>
{
new UiGridColumn
{
HeaderText = "Order Details", TextAlign = UiTextAlign.Center, Columns = new List<UiGridColumn>
{
new UiGridColumn { Field = "ID", HeaderText = "Order ID", Width = 90, TextAlign = UiTextAlign.Right, ShowInColumnChooser = false },
new UiGridColumn { Field = "Name", HeaderText = "Order Name", Width = 180, TextAlign = UiTextAlign.Left },
new UiGridColumn { Field = "OrderDate", HeaderText = "Order Date", Type = UiColumnType.Date, Width = 110, TextAlign = UiTextAlign.Right, Format = "M/d/yyyy" }
}
},
new UiGridColumn
{
HeaderText = "Shipment Details", TextAlign = UiTextAlign.Center, Columns = new List<UiGridColumn>
{
new UiGridColumn { Field = "ShipmentCategory", HeaderText = "Shipment Category", Width = 160, TextAlign = UiTextAlign.Left },
new UiGridColumn { Field = "ShippedDate", HeaderText = "Shipped Date", Type = UiColumnType.Date, Width = 110, TextAlign = UiTextAlign.Right, Format = "M/d/yyyy" },
new UiGridColumn { Field = "Units", HeaderText = "Units", Type = UiColumnType.Number, Width = 70, TextAlign = UiTextAlign.Right }
}
},
new UiGridColumn
{
HeaderText = "Price Details", TextAlign = UiTextAlign.Center, Columns = new List<UiGridColumn>
{
new UiGridColumn { Field = "UnitPrice", HeaderText = "Unit Price", Type = UiColumnType.Number, Width = 115, TextAlign = UiTextAlign.Right, Format = "C2" },
new UiGridColumn { Field = "Price", HeaderText = "Total Price", Type = UiColumnType.Number, Width = 110, TextAlign = UiTextAlign.Right, Format = "C" }
}
}
}
})
@Html.UiTreeGrid(new UiTreeGridOptions
{
Id = "StackedHeader",
Data = ViewData["datasource"],
ChildMapping = "Children",
TreeColumnIndex = 1,
Height = "350px",
AllowPaging = true,
PageCount = 5,
Toolbar = new List<string> { "ColumnChooser" },
Selection = UiGridSelection.Single,
Columns = new List<UiGridColumn>
{
new UiGridColumn
{
HeaderText = "Order Details", TextAlign = UiTextAlign.Center, Columns = new List<UiGridColumn>
{
new UiGridColumn { Field = "ID", HeaderText = "Order ID", Width = 90, TextAlign = UiTextAlign.Right, ShowInColumnChooser = false },
new UiGridColumn { Field = "Name", HeaderText = "Order Name", Width = 180, TextAlign = UiTextAlign.Left },
new UiGridColumn { Field = "OrderDate", HeaderText = "Order Date", Type = UiColumnType.Date, Width = 110, TextAlign = UiTextAlign.Right, Format = "M/d/yyyy" }
}
},
new UiGridColumn
{
HeaderText = "Shipment Details", TextAlign = UiTextAlign.Center, Columns = new List<UiGridColumn>
{
new UiGridColumn { Field = "ShipmentCategory", HeaderText = "Shipment Category", Width = 160, TextAlign = UiTextAlign.Left },
new UiGridColumn { Field = "ShippedDate", HeaderText = "Shipped Date", Type = UiColumnType.Date, Width = 110, TextAlign = UiTextAlign.Right, Format = "M/d/yyyy" },
new UiGridColumn { Field = "Units", HeaderText = "Units", Type = UiColumnType.Number, Width = 70, TextAlign = UiTextAlign.Right }
}
},
new UiGridColumn
{
HeaderText = "Price Details", TextAlign = UiTextAlign.Center, Columns = new List<UiGridColumn>
{
new UiGridColumn { Field = "UnitPrice", HeaderText = "Unit Price", Type = UiColumnType.Number, Width = 115, TextAlign = UiTextAlign.Right, Format = "C2" },
new UiGridColumn { Field = "Price", HeaderText = "Total Price", Type = UiColumnType.Number, Width = 110, TextAlign = UiTextAlign.Right, Format = "C" }
}
}
}
})
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/StackedHeader.cshtml; it draws what ViewData holds.
public ActionResult StackedHeader()
{
var treeData = ShipmentData.GetShipmentData();
ViewData["datasource"] = treeData;
return View();
}
public class ShipmentData
{
public string ID { get; set; }
public string Name { get; set; }
public int Units { get; set; }
public string Category { get; set; }
public int UnitPrice { get; set; }
public int Price { get; set; }
public string ShipmentCategory { get; set; }
public DateTime ShippedDate { get; set; }
public DateTime OrderDate { get; set; }
public List<ShipmentData> Children { get; set; }
public static List<ShipmentData> GetShipmentData()
{
List<ShipmentData> DataCollection = new List<ShipmentData>();
ShipmentData Parent1 = new ShipmentData()
{
ID = "55721",
Name = "Order 1",
Category = "Seafood",
Units = 195,
UnitPrice = 47,
Price = 65565,
OrderDate = new DateTime(2017, 3, 2),
ShippedDate = new DateTime(2017, 9, 2),
ShipmentCategory = "Seafood",
Children = new List<ShipmentData>()
};
ShipmentData Child1 = new ShipmentData()
{
ID = "55722",
Name = "Mackerel",
Category = "Frozen Seafood",
Units = 235,
UnitPrice = 12,
Price = 2820,
OrderDate = new DateTime(2017, 3, 3),
ShippedDate = new DateTime(2017, 10, 3),
ShipmentCategory = "Frozen Seafood"
};
ShipmentData Child2 = new ShipmentData()
{
ID = "55723",
Name = "Yellowfin Tuna",
Category = "Frozen Seafood",
Units = 324,
UnitPrice = 8,
Price = 2592,
OrderDate = new DateTime(2017, 3, 5),
ShippedDate = new DateTime(2017, 10, 5),
ShipmentCategory = "Frozen Seafood"
};
ShipmentData Child3 = new ShipmentData()
{
ID = "55724",
Name = "Herrings",
Category = "Frozen Seafood",
Units = 488,
UnitPrice = 11,
Price = 5368,
OrderDate = new DateTime(2017, 8, 5),
ShippedDate = new DateTime(2017, 5, 15),
ShipmentCategory = "Frozen Seafood"
};
ShipmentData Child4 = new ShipmentData()
{
ID = "55725",
Name = "Preserved Olives",
Category = "Edible",
Units = 125,
UnitPrice = 9,
Price = 1125,
OrderDate = new DateTime(2017, 6, 10),
ShippedDate = new DateTime(2017, 6, 17),
ShipmentCategory = "Edible"
};
ShipmentData Child5 = new ShipmentData()
{
ID = "55726",
Name = " Sweet Corn Frozen ",
Category = "Edible",
Units = 223,
UnitPrice = 7,
Price = 1561,
OrderDate = new DateTime(2017, 7, 12),
ShippedDate = new DateTime(2017, 7, 19),
ShipmentCategory = "Edible"
};
Parent1.Children.Add(Child1);
Parent1.Children.Add(Child2);
Parent1.Children.Add(Child3);
Parent1.Children.Add(Child4);
Parent1.Children.Add(Child5);
ShipmentData Parent2 = new ShipmentData()
{
ID = "55727",
Name = "Order 2",
Category = "Products",
Units = 144,
UnitPrice = 58,
Price = 21233,
OrderDate = new DateTime(2017, 1, 10),
ShippedDate = new DateTime(2017, 1, 16),
ShipmentCategory = "Seafood",
Children = new List<ShipmentData>()
};
ShipmentData Child6 = new ShipmentData()
{
ID = "55728",
Name = "Tilapias",
Category = "Frozen Seafood",
Units = 278,
UnitPrice = 15,
Price = 4170,
OrderDate = new DateTime(2017, 2, 5),
ShippedDate = new DateTime(2017, 2, 12),
ShipmentCategory = "Frozen Seafood"
};
ShipmentData Child7 = new ShipmentData()
{
ID = "55729",
Name = "White Shrimp",
Category = "Frozen Seafood",
Units = 560,
UnitPrice = 7,
Price = 3920,
OrderDate = new DateTime(2017, 5, 22),
ShippedDate = new DateTime(2017, 5, 29),
ShipmentCategory = "Frozen Seafood"
};
ShipmentData Child8 = new ShipmentData()
{
ID = "55730",
Name = "Fresh Cheese",
Category = "Dairy",
Units = 323,
UnitPrice = 12,
Price = 3876,
OrderDate = new DateTime(2017, 6, 8),
ShippedDate = new DateTime(2017, 6, 15),
ShipmentCategory = "Dairy"
};
ShipmentData Child9 = new ShipmentData()
{
ID = "55731",
Name = "Blue Veined Cheese",
Category = "Dairy",
Units = 370,
UnitPrice = 15,
Price = 5550,
OrderDate = new DateTime(2017, 7, 10),
ShippedDate = new DateTime(2017, 7, 17),
ShipmentCategory = "Dairy"
};
ShipmentData Child10 = new ShipmentData()
{
ID = "55732",
Name = "Butter",
Category = "Dairy",
Units = 413,
UnitPrice = 9,
Price = 3717,
OrderDate = new DateTime(2017, 9, 18),
ShippedDate = new DateTime(2017, 9, 25),
ShipmentCategory = "Dairy"
};
Parent2.Children.Add(Child6);
Parent2.Children.Add(Child7);
Parent2.Children.Add(Child8);
Parent2.Children.Add(Child9);
Parent2.Children.Add(Child10);
ShipmentData Parent3 = new ShipmentData()
{
ID = "55733",
Name = "Order 3",
Category = "Crystals",
Units = 144,
UnitPrice = 58,
Price = 21233,
OrderDate = new DateTime(2017, 9, 10),
ShippedDate = new DateTime(2017, 9, 20),
ShipmentCategory = "Crystals",
Children = new List<ShipmentData>()
};
ShipmentData Child11 = new ShipmentData()
{
ID = "55734",
Name = "Lead Glassware",
Category = "Solid Crystals",
Units = 542,
UnitPrice = 6,
Price = 3252,
OrderDate = new DateTime(2017, 2, 7),
ShippedDate = new DateTime(2017, 2, 14),
ShipmentCategory = "Solid Crystals"
};
ShipmentData Child12 = new ShipmentData()
{
ID = "55735",
Name = "Pharmaceutical Glass",
Category = "Solid Crystals",
Units = 324,
UnitPrice = 11,
Price = 3564,
OrderDate = new DateTime(2017, 4, 19),
ShippedDate = new DateTime(2017, 4, 26),
ShipmentCategory = "Solid Crystals"
};
ShipmentData Child13 = new ShipmentData()
{
ID = "55736",
Name = "Glass Beads",
Category = "Solid Crystals",
Units = 254,
UnitPrice = 16,
Price = 4064,
OrderDate = new DateTime(2017, 5, 22),
ShippedDate = new DateTime(2017, 3, 22),
ShipmentCategory = "Solid Crystals"
};
Parent3.Children.Add(Child11);
Parent3.Children.Add(Child12);
Parent3.Children.Add(Child13);
DataCollection.Add(Parent1);
DataCollection.Add(Parent2);
DataCollection.Add(Parent3);
return DataCollection;
}
}
}
}
@* 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>