From c63fdce3731f02abcd317045ed8263382b546b36 Mon Sep 17 00:00:00 2001 From: dhanushaSF4765 Date: Fri, 12 Jun 2026 14:17:10 +0530 Subject: [PATCH 01/18] 1032923: databinding changed --- blazor/treegrid/data-binding.md | 240 +++++++++++++++++++++++++------- 1 file changed, 186 insertions(+), 54 deletions(-) diff --git a/blazor/treegrid/data-binding.md b/blazor/treegrid/data-binding.md index 305cacc497..1b700dc3ed 100644 --- a/blazor/treegrid/data-binding.md +++ b/blazor/treegrid/data-binding.md @@ -258,6 +258,7 @@ ExpandoObject can be bound to Tree grid by assigning to the [DataSource](https:/ ```cshtml @using Syncfusion.Blazor.TreeGrid; +@using System.Dynamic; @@ -528,6 +529,7 @@ The following example demonstrates how to use this approach in a TreeGrid: @using Syncfusion.Blazor.TreeGrid @using Syncfusion.Blazor.Buttons @using System.Collections.ObjectModel +@using System.Collections.Specialized
@@ -706,119 +708,233 @@ Similarly, if the user navigates to a new page, the root nodes of that specific **Service code snippet** -```ts +```c# + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Dynamic.Core; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Cors; +using Microsoft.Extensions.Primitives; +using System.ComponentModel.DataAnnotations; +using System.Collections; namespace Sample.Controllers { - [Route("api/SelfReferenceDatacontroller")] - [ApiController] - - public class SelfReferenceDataController : ControllerBase + public class SelfReferenceDataController : Controller { public static List FlatData = new List(); - - // GET: api/SelfReferenceDataController> + // GET: api/SelfReferenceData + [Route("api/SelfReferenceData")] [HttpGet] + [EnableCors("AllowAllOrigins")] public object Get() { - var queryString = Request.Query; FlatData.Clear(); + var queryString = Request.Query; if (SelfReferenceData.tree.Count == 0) SelfReferenceData.GetTree(); - List data = SelfReferenceData.tree.ToList(); - bool isFiltered = false; - if (queryString.Keys.Contains("$filter")) + DataRequest req = QueryGenerator(queryString); + if (req.filter != "" && !req.filter.Contains("null")) { - StringValues filter; - isFiltered = true; - queryString.TryGetValue("$filter", out filter); - string[] filterQuery = null; - if (filter[0].IndexOf('(') != -1 && filter[0].IndexOf(')') != -1) + int fltr = Int32.Parse(req.filter.Split("eq")[1]); + IQueryable data1 = SelfReferenceData.tree.Where(f => f.ParentItem == fltr).AsQueryable(); + if (queryString.Keys.Contains("$orderby")) { - filterQuery = filter[0].Split('(', ')')[1].Split(" eq "); + string srt; + srt = req.orderby.Replace("desc", "descending"); + data1 = SortingExtend.Sort(data1, srt); } + return new { result = data1.ToList(), items = data1.ToList(), count = data1.Count() }; + } + List data = SelfReferenceData.tree.ToList(); + if (req.orderby != "") + { + string srt; + srt = req.orderby.Replace("desc", "descending"); + IQueryable data1 = SortingExtend.Sort(data.AsQueryable(), srt); + data = data1.ToList(); + } + if (queryString.Keys.Contains("$select")) + { + data = (from ord in SelfReferenceData.tree + select new SelfReferenceData + { + ParentItem = ord.ParentItem + } + ).ToList(); + return data; + } + data = data.Where(p => p.ParentItem == null).ToList(); + int count = data.Count; + if (req.inlinecount) + { + if (req.skip == null) + FlatData = data; else + FlatData = data.Skip((int)req.skip).Take((int)req.take).ToList(); + if (req.loadchild) { - filterQuery = filter[0].Split(" eq "); - } - var field = filterQuery[0]; - var value = filterQuery[1]; - if (field == "ParentID" && value == "null") - { - data = data.Where(p => p.ParentID == null).ToList(); + var GroupData = SelfReferenceData.tree.ToList().GroupBy(rec => rec.ParentItem) + .Where(g => g.Key != null).ToDictionary(g => g.Key?.ToString(), g => g.ToList()); + foreach (var Record in FlatData.ToList()) + { + if (GroupData.ContainsKey(Record.TaskID.ToString())) + { + var ChildGroup = GroupData[Record.TaskID.ToString()]; + if (ChildGroup?.Count > 0) + AppendChildren(ChildGroup, Record, GroupData); + } + } } + if (req.skip == null && req.take == null) + return new { result = FlatData, items = FlatData, count = count }; + return new { result = FlatData, items = FlatData, count = count }; } + else + { + return SelfReferenceData.GetTree(); + } + } + + public DataRequest QueryGenerator(IQueryCollection queryString) + { + DataRequest req = new DataRequest(); + StringValues Skip; + StringValues Take; + StringValues filter; + StringValues orderby; + StringValues loadchild; + req.loadchild = queryString.TryGetValue("loadchildondemand", out loadchild) ? Convert.ToBoolean(loadchild[0]) : false; + req.skip = queryString.TryGetValue("$skip", out Skip) ? Convert.ToInt32(Skip[0]) : (Nullable)null; + req.take = (queryString.TryGetValue("$top", out Take)) ? Convert.ToInt32(Take[0]) : (Nullable)null; + req.filter = queryString.TryGetValue("$filter", out filter) ? filter[0].ToString() : ""; + req.inlinecount = queryString.Keys.Contains("$inlinecount") ? true : false; + req.orderby = queryString.TryGetValue("$orderby", out orderby) ? orderby[0].ToString() : ""; + return req; + } + + + private void AppendChildren(List ChildRecords, SelfReferenceData ParentItem, Dictionary> GroupData) + { + var queryString = Request.Query; + string TaskId = ParentItem.TaskID.ToString(); if (queryString.Keys.Contains("$orderby")) { StringValues srt; queryString.TryGetValue("$orderby", out srt); srt = srt.ToString().Replace("desc", "descending"); - IQueryable data1 = SortingExtend.Sort(data.AsQueryable(), srt); - data = data1.ToList(); - } - int count = data.Count; - if (queryString.Keys.Contains("$inlinecount")) - { - StringValues Skip; - StringValues Take; - int skip = (queryString.TryGetValue("$skip", out Skip)) ? Convert.ToInt32(Skip[0]) : 0; - int top = (queryString.TryGetValue("$top", out Take)) ? Convert.ToInt32(Take[0]) : data.Count(); - FlatData = data.Skip(skip).Take(top).ToList(); - - return new { Items = FlatData, FlatData.Count }; + List SortedChildRecords = SortingExtend.Sort(ChildRecords.AsQueryable(), srt).ToList(); + var index = FlatData.IndexOf(ParentItem); + foreach (var Child in SortedChildRecords) + { + string ParentId = Child.ParentItem.ToString(); + if (TaskId == ParentId) + { + if (FlatData.IndexOf(Child) == -1) + ((IList)FlatData).Insert(++index, Child); + if (GroupData.ContainsKey(Child.TaskID.ToString())) + { + var DeepChildRecords = GroupData[Child.TaskID.ToString()]; + if (DeepChildRecords?.Count > 0) + AppendChildren(DeepChildRecords, Child, GroupData); + } + } + } } else { - return SelfReferenceData.GetTree(); + var index = FlatData.IndexOf(ParentItem); + foreach (var Child in ChildRecords) + { + string ParentId = Child.ParentItem.ToString(); + if (TaskId == ParentId) + { + if (FlatData.IndexOf(Child) == -1) + ((IList)FlatData).Insert(++index, Child); + if (GroupData.ContainsKey(Child.TaskID.ToString())) + { + var DeepChildRecords = GroupData[Child.TaskID.ToString()]; + if (DeepChildRecords?.Count > 0) + AppendChildren(DeepChildRecords, Child, GroupData); + } + } + } } } - + } -public class SelfReferenceData + public static class SortingExtend + { + public static IQueryable Sort(this IQueryable source, string sortBy) + { + if (source == null) + throw new ArgumentNullException("source"); + + if (string.IsNullOrEmpty(sortBy)) + throw new ArgumentNullException("sortBy"); + + source = source.OrderBy(sortBy); + + return source; + } + } + public class DataRequest + { + public Nullable skip { get; set; } + public Nullable take { get; set; } + public Boolean inlinecount { get; set; } + public string filter { get; set; } + public string orderby { get; set; } + public bool loadchild { get; set; } + } + public class SelfReferenceData { public static List tree = new List(); - public int? TaskID { get; set; } + [Key] + public int TaskID { get; set; } public string TaskName { get; set; } public DateTime StartDate { get; set; } public DateTime EndDate { get; set; } public String Progress { get; set; } public String Priority { get; set; } public int Duration { get; set; } - public int? ParentID { get; set; } + public int? ParentItem { get; set; } public bool? isParent { get; set; } public SelfReferenceData() { } public static List GetTree() { - tree.Clear(); if (tree.Count == 0) { int root = -1; - for (var t = 1; t <= 10; t++) + for (var t = 1; t <= 60; t++) { - Random ran = new Random(); - string math = (ran.Next() % 3) == 0 ? "High" : (ran.Next() % 2) == 0 ? "Release Breaker" : "Critical"; - string progr = (ran.Next() % 3) == 0 ? "Started" : (ran.Next() % 2) == 0 ? "Open" : "In Progress"; + int duration = (t % 2 == 0) ? 52 : (t % 5 == 0) ? 14 : (t % 3 == 0) ? 25 : 34; + string math = (t % 3) == 0 ? "High" : (t % 2) == 0 ? "Release Breaker" : "Critical"; + string progr = (t % 3) == 0 ? "Started" : (t % 2) == 0 ? "Open" : "In Progress"; root++; int rootItem = tree.Count + root + 1; - tree.Add(new SelfReferenceData() { TaskID = rootItem, TaskName = "Parent Task " + rootItem.ToString(), StartDate = new DateTime(1992, 06, 07), EndDate = new DateTime(1994, 08, 25), isParent = true, Progress = progr, Priority = math, Duration = ran.Next(1, 50) }); + tree.Add(new SelfReferenceData() { TaskID = rootItem, TaskName = "Parent Task " + rootItem.ToString(), StartDate = new DateTime(1992, 06, 07), EndDate = new DateTime(1994, 08, 25), isParent = true, ParentItem = null, Progress = progr, Priority = math, Duration = duration }); int parent = tree.Count; - for (var c = 0; c < 3; c++) + for (var c = 0; c < 10; c++) { root++; string val = ((parent + c + 1) % 3 == 0) ? "Low" : "Critical"; int parn = parent + c + 1; - progr = (ran.Next() % 3) == 0 ? "In Progress" : (ran.Next() % 2) == 0 ? "Open" : "Validated"; + progr = (t % 3) == 0 ? "In Progress" : (t % 2) == 0 ? "Open" : "Validated"; int iD = tree.Count + root + 1; - tree.Add(new SelfReferenceData() { TaskID = iD, TaskName = "Child Task " + iD.ToString(), StartDate = new DateTime(1992, 06, 07), EndDate = new DateTime(1994, 08, 25), isParent = (((parent + c + 1) % 3) == 0), ParentID = rootItem, Progress = progr, Priority = val, Duration = ran.Next(1, 50) }); + tree.Add(new SelfReferenceData() { TaskID = iD, TaskName = "Child Task " + iD.ToString(), StartDate = new DateTime(1992, 06, 07), EndDate = new DateTime(1994, 08, 25), isParent = (((parent + c + 1) % 3) == 0), ParentItem = rootItem, Progress = progr, Priority = val, Duration = duration }); if ((((parent + c + 1) % 3) == 0)) { int immParent = tree.Count; - for (var s = 0; s <= 1; s++) + for (var s = 0; s < 3; s++) { root++; string Prior = (immParent % 2 == 0) ? "Validated" : "Normal"; - tree.Add(new SelfReferenceData() { TaskID = tree.Count + root + 1, TaskName = "Sub Task " + (tree.Count + root + 1).ToString(), StartDate = new DateTime(1992, 06, 07), EndDate = new DateTime(1994, 08, 25), isParent = false, ParentID = iD, Progress = (immParent % 2 == 0) ? "On Progress" : "Closed", Priority = Prior, Duration = ran.Next(1, 50) }); + tree.Add(new SelfReferenceData() { TaskID = tree.Count + root + 1, TaskName = "Sub Task " + (tree.Count + root + 1).ToString(), StartDate = new DateTime(1992, 06, 07), EndDate = new DateTime(1994, 08, 25), isParent = false, ParentItem = iD, Progress = (immParent % 2 == 0) ? "On Progress" : "Closed", Priority = Prior, Duration = duration }); } } } @@ -826,9 +942,9 @@ public class SelfReferenceData } return tree; } -} } } + ``` N> * By default, **SfDataManager** uses **ODataAdaptor** for remote data-binding. @@ -855,7 +971,23 @@ On remote data binding, all tree grid actions such as paging, loading child on-d +@code{ + public class BusinessObject + { + public int TaskID { get; set; } + public string TaskName { get; set; } + public DateTime? StartDate { get; set; } + public DateTime? EndDate { get; set; } + public String Progress { get; set; } + public String Priority { get; set; } + public double? Duration { get; set; } + public int? ParentID { get; set; } + public bool? isParent { get; set; } + public bool? Approved { get; set; } + public int? ParentItem { get; set; } + } +} ``` ### LoadChildOnDemand From 1dd448b01b5bdd87adba0c8ca37e625f5f79c765 Mon Sep 17 00:00:00 2001 From: dhanushaSF4765 Date: Fri, 12 Jun 2026 14:30:00 +0530 Subject: [PATCH 02/18] 1032923: paging sample updated --- blazor/treegrid/paging.md | 188 +++++++++++++++++++++++++------------- 1 file changed, 125 insertions(+), 63 deletions(-) diff --git a/blazor/treegrid/paging.md b/blazor/treegrid/paging.md index 3caa45c6d2..dd4da10910 100644 --- a/blazor/treegrid/paging.md +++ b/blazor/treegrid/paging.md @@ -16,25 +16,28 @@ Paging provides an option to display Tree Grid data in page segments. To enable {% highlight razor %} @using TreeGridComponent.Data; -@using Syncfusion.Blazor.TreeGrid; +@using Syncfusion.Blazor.TreeGrid +@using Syncfusion.Blazor.Grids - + - - - - - + + + + + + + @code{ - public List TreeGridData { get; set; } + private List TreeData { get; set; } = new List(); protected override void OnInitialized() { - this.TreeGridData = TreeData.GetSelfDataSource().ToList(); + TreeData = WrapData.GetWrapData().ToList(); } } @@ -44,30 +47,58 @@ Paging provides an option to display Tree Grid data in page segments. To enable namespace TreeGridComponent.Data { -public class TreeData + public class WrapData { - public class BusinessObject - { - public int TaskId { get; set;} - public string TaskName { get; set;} - public int? Duration { get; set;} - public int? Progress { get; set;} - public string Priority { get; set;} - public int? ParentId { get; set;} - } - - public static List GetSelfDataSource() + 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 string? Progress { get; set; } + public string? Priority { get; set; } + public bool Approved { get; set; } + public int Resources { get; set; } + public int? ParentId { get; set; } + public static List GetWrapData() { - List BusinessObjectCollection = new List(); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1,TaskName = "Parent Task 1",Duration = 10,Progress = 70,Priority = "Critical",ParentId = null }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2,TaskName = "Child task 1",Progress = 80,Priority = "Low",ParentId = 1 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3,TaskName = "Child Task 2",Duration = 5,Progress = 65,Priority = "Critical",ParentId = 2 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4,TaskName = "Child task 3",Duration = 6,Priority = "High",Progress = 77,ParentId = 3 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5,TaskName = "Parent Task 2",Duration = 10,Progress = 70,Priority = "Critical",ParentId = null}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6,TaskName = "Child task 1",Duration = 4,Progress = 80,Priority = "Critical",ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7,TaskName = "Child Task 2",Duration = 5,Progress = 65,Priority = "Low",ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8,TaskName = "Child task 3",Duration = 6,Progress = 77,Priority = "High",ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9,TaskName = "Child task 4",Duration = 6,Progress = 77,Priority = "Low",ParentId = 5}); + List BusinessObjectCollection = new List(); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4871, TaskName = "Planning", StartDate = new DateTime(2025, 3, 2), EndDate = new DateTime(2025, 7, 11), Progress = "Open", Duration = 132, Priority = "Normal", Resources = 6, Approved = false, ParentId = null }); // Mar 2 ? Jul 11 + BusinessObjectCollection.Add(new WrapData() { TaskId = 4872, TaskName = "Plan timeline", StartDate = new DateTime(2025, 3, 4), EndDate = new DateTime(2025, 3, 8), Progress = "In Progress", Duration = 5, Resources = 4, Priority = "Normal", Approved = false, ParentId = 4871 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4873, TaskName = "Plan budget", StartDate = new DateTime(2025, 3, 6), EndDate = new DateTime(2025, 3, 10), Duration = 5, Progress = "Started", Approved = true, Resources = 6, Priority = "Low", ParentId = 4871 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4874, TaskName = "Allocate resources", StartDate = new DateTime(2025, 3, 8), EndDate = new DateTime(2025, 3, 12), Duration = 5, Progress = "Open", Priority = "Critical", Resources = 3, Approved = false, ParentId = 4871 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4875, TaskName = "Planning complete", StartDate = new DateTime(2025, 7, 10), EndDate = new DateTime(2025, 7, 11), Duration = 2, Progress = "Open", Priority = "Low", Resources = 5, ParentId = 4871, Approved = true }); + + BusinessObjectCollection.Add(new WrapData() { TaskId = 4876, TaskName = "Design", StartDate = new DateTime(2025, 7, 15), EndDate = new DateTime(2025, 9, 20), Progress = "In Progress", Duration = 68, Priority = "High", Resources = 4, Approved = false, ParentId = null }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4877, TaskName = "Software specification", StartDate = new DateTime(2025, 7, 16), EndDate = new DateTime(2025, 7, 25), Duration = 10, Progress = "Started", Resources = 3, Priority = "Normal", ParentId = 4876, Approved = false }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4878, TaskName = "Develop prototype", StartDate = new DateTime(2025, 7, 26), EndDate = new DateTime(2025, 8, 10), Duration = 16, Progress = "In Progress", Resources = 2, Priority = "Critical", ParentId = 4876, Approved = false }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4879, TaskName = "Get approval from customer", StartDate = new DateTime(2025, 8, 11), EndDate = new DateTime(2025, 8, 15), Duration = 5, Progress = "In Progress", Resources = 3, Priority = "Low", Approved = true, ParentId = 4876 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4880, TaskName = "Design complete", StartDate = new DateTime(2025, 9, 18), EndDate = new DateTime(2025, 9, 20), Duration = 3, Progress = "In Progress", Resources = 6, Priority = "Normal", ParentId = 4876, Approved = true }); + + BusinessObjectCollection.Add(new WrapData() { TaskId = 4881, TaskName = "Implementation phase", StartDate = new DateTime(2025, 9, 21), EndDate = new DateTime(2025, 12, 31), Priority = "Normal", Approved = false, Duration = 102, Resources = 5, Progress = "Started", ParentId = null }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4882, TaskName = "Phase 1", StartDate = new DateTime(2025, 9, 22), EndDate = new DateTime(2025, 10, 15), Priority = "High", Approved = false, Duration = 24, Progress = "Open", Resources = 4, ParentId = 4881 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4883, TaskName = "Implementation module 1", StartDate = new DateTime(2025, 9, 23), EndDate = new DateTime(2025, 10, 14), Priority = "Normal", Duration = 22, Progress = "Started", Resources = 3, Approved = false, ParentId = 4882 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4884, TaskName = "Development task 1", StartDate = new DateTime(2025, 9, 24), EndDate = new DateTime(2025, 9, 28), Duration = 5, Progress = "In Progress", Priority = "High", Resources = 2, ParentId = 4883, Approved = false }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4885, TaskName = "Development task 2", StartDate = new DateTime(2025, 9, 29), EndDate = new DateTime(2025, 10, 3), Duration = 5, Progress = "Closed", Priority = "Low", Resources = 5, ParentId = 4883, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4886, TaskName = "Testing", StartDate = new DateTime(2025, 10, 4), EndDate = new DateTime(2025, 10, 7), Duration = 4, Progress = "Closed", Priority = "Normal", ParentId = 4883, Resources = 1, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4887, TaskName = "Bug fix", StartDate = new DateTime(2025, 10, 8), EndDate = new DateTime(2025, 10, 10), Duration = 3, Progress = "Validated", Priority = "Critical", ParentId = 4883, Resources = 6, Approved = false }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4888, TaskName = "Customer review meeting", StartDate = new DateTime(2025, 10, 11), EndDate = new DateTime(2025, 10, 14), Duration = 4, Progress = "Open", Priority = "High", ParentId = 4883, Resources = 6, Approved = false }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4889, TaskName = "Phase 1 complete", StartDate = new DateTime(2025, 10, 14), EndDate = new DateTime(2025, 10, 15), Duration = 2, Progress = "Closed", Priority = "Low", ParentId = 4883, Resources = 5, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4890, TaskName = "Phase 2", StartDate = new DateTime(2025, 10, 16), EndDate = new DateTime(2025, 11, 15), Priority = "High", Approved = false, Progress = "Open", ParentId = 4881, Resources = 3, Duration = 31 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4891, TaskName = "Implementation module 2", StartDate = new DateTime(2025, 10, 17), EndDate = new DateTime(2025, 11, 14), Priority = "Critical", Approved = false, Progress = "In Progress", ParentId = 4890, Resources = 3, Duration = 29 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4892, TaskName = "Development task 1", StartDate = new DateTime(2025, 10, 18), EndDate = new DateTime(2025, 10, 25), Duration = 8, Progress = "Closed", Priority = "Normal", ParentId = 4891, Resources = 2, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4893, TaskName = "Development task 2", StartDate = new DateTime(2025, 10, 26), EndDate = new DateTime(2025, 11, 2), Duration = 8, Progress = "Closed", Priority = "Critical", ParentId = 4891, Resources = 5, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4894, TaskName = "Testing", StartDate = new DateTime(2025, 11, 3), EndDate = new DateTime(2025, 11, 6), Duration = 4, Progress = "Open", Priority = "High", ParentId = 4891, Resources = 3, Approved = false }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4895, TaskName = "Bug fix", StartDate = new DateTime(2025, 11, 7), EndDate = new DateTime(2025, 11, 10), Duration = 4, Progress = "Validated", Priority = "Low", Approved = false, Resources = 6, ParentId = 4891 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4896, TaskName = "Customer review meeting", StartDate = new DateTime(2025, 11, 11), EndDate = new DateTime(2025, 11, 14), Duration = 4, Progress = "In Progress", Priority = "Critical", ParentId = 4891, Resources = 4, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4897, TaskName = "Phase 2 complete", StartDate = new DateTime(2025, 11, 14), EndDate = new DateTime(2025, 11, 15), Duration = 2, Priority = "Normal", Progress = "Open", ParentId = 4891, Resources = 3, Approved = false }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4898, TaskName = "Phase 3", StartDate = new DateTime(2025, 11, 16), EndDate = new DateTime(2025, 12, 20), Priority = "Normal", Approved = false, Duration = 35, Progress = "In Progress", Resources = 4, ParentId = 4881 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4899, TaskName = "Implementation module 3", StartDate = new DateTime(2025, 11, 17), EndDate = new DateTime(2025, 12, 19), Priority = "High", Approved = false, Duration = 33, Resources = 5, Progress = "Validated", ParentId = 4898 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4900, TaskName = "Development task 1", StartDate = new DateTime(2025, 11, 18), EndDate = new DateTime(2025, 11, 25), Duration = 8, Progress = "Closed", Priority = "Low", Approved = true, Resources = 3, ParentId = 4899 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4901, TaskName = "Development task 2", StartDate = new DateTime(2025, 11, 26), EndDate = new DateTime(2025, 12, 3), Duration = 8, Progress = "Closed", Priority = "Normal", Approved = false, Resources = 2, ParentId = 4899 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4902, TaskName = "Testing", StartDate = new DateTime(2025, 12, 4), EndDate = new DateTime(2025, 12, 10), Duration = 7, Progress = "Closed", Priority = "Critical", ParentId = 4899, Resources = 4, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4903, TaskName = "Bug fix", StartDate = new DateTime(2025, 12, 11), EndDate = new DateTime(2025, 12, 15), Duration = 5, Progress = "Open", Priority = "High", Approved = false, Resources = 3, ParentId = 4899 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4904, TaskName = "Customer review meeting", StartDate = new DateTime(2025, 12, 16), EndDate = new DateTime(2025, 12, 19), Duration = 4, Progress = "In Progress", Priority = "Normal", ParentId = 4899, Resources = 6, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4905, TaskName = "Phase 3 complete", StartDate = new DateTime(2025, 12, 19), EndDate = new DateTime(2025, 12, 20), Duration = 2, Priority = "Critical", Progress = "Open", Resources = 5, ParentId = 4899, Approved = false }); return BusinessObjectCollection; } } @@ -96,25 +127,28 @@ N> The **ALL** mode of **PageSizeMode** is not supported with remote data bindin {% highlight razor %} @using TreeGridComponent.Data; -@using Syncfusion.Blazor.TreeGrid; +@using Syncfusion.Blazor.TreeGrid +@using Syncfusion.Blazor.Grids - + - - - - - + + + + + + + @code{ - public List TreeGridData { get; set; } + private List TreeData { get; set; } = new List(); protected override void OnInitialized() { - this.TreeGridData = TreeData.GetSelfDataSource().ToList(); + TreeData = WrapData.GetWrapData().ToList(); } } @@ -124,30 +158,58 @@ N> The **ALL** mode of **PageSizeMode** is not supported with remote data bindin namespace TreeGridComponent.Data { -public class TreeData + public class WrapData { - public class BusinessObject - { - public int TaskId { get; set;} - public string TaskName { get; set;} - public int? Duration { get; set;} - public int? Progress { get; set;} - public string Priority { get; set;} - public int? ParentId { get; set;} - } - - public static List GetSelfDataSource() + 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 string? Progress { get; set; } + public string? Priority { get; set; } + public bool Approved { get; set; } + public int Resources { get; set; } + public int? ParentId { get; set; } + public static List GetWrapData() { - List BusinessObjectCollection = new List(); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1,TaskName = "Parent Task 1",Duration = 10,Progress = 70,Priority = "Critical",ParentId = null }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2,TaskName = "Child task 1",Progress = 80,Priority = "Low",ParentId = 1 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3,TaskName = "Child Task 2",Duration = 5,Progress = 65,Priority = "Critical",ParentId = 2 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4,TaskName = "Child task 3",Duration = 6,Priority = "High",Progress = 77,ParentId = 3 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5,TaskName = "Parent Task 2",Duration = 10,Progress = 70,Priority = "Critical",ParentId = null}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6,TaskName = "Child task 1",Duration = 4,Progress = 80,Priority = "Critical",ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7,TaskName = "Child Task 2",Duration = 5,Progress = 65,Priority = "Low",ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8,TaskName = "Child task 3",Duration = 6,Progress = 77,Priority = "High",ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9,TaskName = "Child task 4",Duration = 6,Progress = 77,Priority = "Low",ParentId = 5}); + List BusinessObjectCollection = new List(); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4871, TaskName = "Planning", StartDate = new DateTime(2025, 3, 2), EndDate = new DateTime(2025, 7, 11), Progress = "Open", Duration = 132, Priority = "Normal", Resources = 6, Approved = false, ParentId = null }); // Mar 2 ? Jul 11 + BusinessObjectCollection.Add(new WrapData() { TaskId = 4872, TaskName = "Plan timeline", StartDate = new DateTime(2025, 3, 4), EndDate = new DateTime(2025, 3, 8), Progress = "In Progress", Duration = 5, Resources = 4, Priority = "Normal", Approved = false, ParentId = 4871 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4873, TaskName = "Plan budget", StartDate = new DateTime(2025, 3, 6), EndDate = new DateTime(2025, 3, 10), Duration = 5, Progress = "Started", Approved = true, Resources = 6, Priority = "Low", ParentId = 4871 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4874, TaskName = "Allocate resources", StartDate = new DateTime(2025, 3, 8), EndDate = new DateTime(2025, 3, 12), Duration = 5, Progress = "Open", Priority = "Critical", Resources = 3, Approved = false, ParentId = 4871 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4875, TaskName = "Planning complete", StartDate = new DateTime(2025, 7, 10), EndDate = new DateTime(2025, 7, 11), Duration = 2, Progress = "Open", Priority = "Low", Resources = 5, ParentId = 4871, Approved = true }); + + BusinessObjectCollection.Add(new WrapData() { TaskId = 4876, TaskName = "Design", StartDate = new DateTime(2025, 7, 15), EndDate = new DateTime(2025, 9, 20), Progress = "In Progress", Duration = 68, Priority = "High", Resources = 4, Approved = false, ParentId = null }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4877, TaskName = "Software specification", StartDate = new DateTime(2025, 7, 16), EndDate = new DateTime(2025, 7, 25), Duration = 10, Progress = "Started", Resources = 3, Priority = "Normal", ParentId = 4876, Approved = false }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4878, TaskName = "Develop prototype", StartDate = new DateTime(2025, 7, 26), EndDate = new DateTime(2025, 8, 10), Duration = 16, Progress = "In Progress", Resources = 2, Priority = "Critical", ParentId = 4876, Approved = false }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4879, TaskName = "Get approval from customer", StartDate = new DateTime(2025, 8, 11), EndDate = new DateTime(2025, 8, 15), Duration = 5, Progress = "In Progress", Resources = 3, Priority = "Low", Approved = true, ParentId = 4876 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4880, TaskName = "Design complete", StartDate = new DateTime(2025, 9, 18), EndDate = new DateTime(2025, 9, 20), Duration = 3, Progress = "In Progress", Resources = 6, Priority = "Normal", ParentId = 4876, Approved = true }); + + BusinessObjectCollection.Add(new WrapData() { TaskId = 4881, TaskName = "Implementation phase", StartDate = new DateTime(2025, 9, 21), EndDate = new DateTime(2025, 12, 31), Priority = "Normal", Approved = false, Duration = 102, Resources = 5, Progress = "Started", ParentId = null }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4882, TaskName = "Phase 1", StartDate = new DateTime(2025, 9, 22), EndDate = new DateTime(2025, 10, 15), Priority = "High", Approved = false, Duration = 24, Progress = "Open", Resources = 4, ParentId = 4881 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4883, TaskName = "Implementation module 1", StartDate = new DateTime(2025, 9, 23), EndDate = new DateTime(2025, 10, 14), Priority = "Normal", Duration = 22, Progress = "Started", Resources = 3, Approved = false, ParentId = 4882 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4884, TaskName = "Development task 1", StartDate = new DateTime(2025, 9, 24), EndDate = new DateTime(2025, 9, 28), Duration = 5, Progress = "In Progress", Priority = "High", Resources = 2, ParentId = 4883, Approved = false }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4885, TaskName = "Development task 2", StartDate = new DateTime(2025, 9, 29), EndDate = new DateTime(2025, 10, 3), Duration = 5, Progress = "Closed", Priority = "Low", Resources = 5, ParentId = 4883, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4886, TaskName = "Testing", StartDate = new DateTime(2025, 10, 4), EndDate = new DateTime(2025, 10, 7), Duration = 4, Progress = "Closed", Priority = "Normal", ParentId = 4883, Resources = 1, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4887, TaskName = "Bug fix", StartDate = new DateTime(2025, 10, 8), EndDate = new DateTime(2025, 10, 10), Duration = 3, Progress = "Validated", Priority = "Critical", ParentId = 4883, Resources = 6, Approved = false }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4888, TaskName = "Customer review meeting", StartDate = new DateTime(2025, 10, 11), EndDate = new DateTime(2025, 10, 14), Duration = 4, Progress = "Open", Priority = "High", ParentId = 4883, Resources = 6, Approved = false }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4889, TaskName = "Phase 1 complete", StartDate = new DateTime(2025, 10, 14), EndDate = new DateTime(2025, 10, 15), Duration = 2, Progress = "Closed", Priority = "Low", ParentId = 4883, Resources = 5, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4890, TaskName = "Phase 2", StartDate = new DateTime(2025, 10, 16), EndDate = new DateTime(2025, 11, 15), Priority = "High", Approved = false, Progress = "Open", ParentId = 4881, Resources = 3, Duration = 31 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4891, TaskName = "Implementation module 2", StartDate = new DateTime(2025, 10, 17), EndDate = new DateTime(2025, 11, 14), Priority = "Critical", Approved = false, Progress = "In Progress", ParentId = 4890, Resources = 3, Duration = 29 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4892, TaskName = "Development task 1", StartDate = new DateTime(2025, 10, 18), EndDate = new DateTime(2025, 10, 25), Duration = 8, Progress = "Closed", Priority = "Normal", ParentId = 4891, Resources = 2, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4893, TaskName = "Development task 2", StartDate = new DateTime(2025, 10, 26), EndDate = new DateTime(2025, 11, 2), Duration = 8, Progress = "Closed", Priority = "Critical", ParentId = 4891, Resources = 5, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4894, TaskName = "Testing", StartDate = new DateTime(2025, 11, 3), EndDate = new DateTime(2025, 11, 6), Duration = 4, Progress = "Open", Priority = "High", ParentId = 4891, Resources = 3, Approved = false }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4895, TaskName = "Bug fix", StartDate = new DateTime(2025, 11, 7), EndDate = new DateTime(2025, 11, 10), Duration = 4, Progress = "Validated", Priority = "Low", Approved = false, Resources = 6, ParentId = 4891 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4896, TaskName = "Customer review meeting", StartDate = new DateTime(2025, 11, 11), EndDate = new DateTime(2025, 11, 14), Duration = 4, Progress = "In Progress", Priority = "Critical", ParentId = 4891, Resources = 4, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4897, TaskName = "Phase 2 complete", StartDate = new DateTime(2025, 11, 14), EndDate = new DateTime(2025, 11, 15), Duration = 2, Priority = "Normal", Progress = "Open", ParentId = 4891, Resources = 3, Approved = false }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4898, TaskName = "Phase 3", StartDate = new DateTime(2025, 11, 16), EndDate = new DateTime(2025, 12, 20), Priority = "Normal", Approved = false, Duration = 35, Progress = "In Progress", Resources = 4, ParentId = 4881 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4899, TaskName = "Implementation module 3", StartDate = new DateTime(2025, 11, 17), EndDate = new DateTime(2025, 12, 19), Priority = "High", Approved = false, Duration = 33, Resources = 5, Progress = "Validated", ParentId = 4898 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4900, TaskName = "Development task 1", StartDate = new DateTime(2025, 11, 18), EndDate = new DateTime(2025, 11, 25), Duration = 8, Progress = "Closed", Priority = "Low", Approved = true, Resources = 3, ParentId = 4899 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4901, TaskName = "Development task 2", StartDate = new DateTime(2025, 11, 26), EndDate = new DateTime(2025, 12, 3), Duration = 8, Progress = "Closed", Priority = "Normal", Approved = false, Resources = 2, ParentId = 4899 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4902, TaskName = "Testing", StartDate = new DateTime(2025, 12, 4), EndDate = new DateTime(2025, 12, 10), Duration = 7, Progress = "Closed", Priority = "Critical", ParentId = 4899, Resources = 4, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4903, TaskName = "Bug fix", StartDate = new DateTime(2025, 12, 11), EndDate = new DateTime(2025, 12, 15), Duration = 5, Progress = "Open", Priority = "High", Approved = false, Resources = 3, ParentId = 4899 }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4904, TaskName = "Customer review meeting", StartDate = new DateTime(2025, 12, 16), EndDate = new DateTime(2025, 12, 19), Duration = 4, Progress = "In Progress", Priority = "Normal", ParentId = 4899, Resources = 6, Approved = true }); + BusinessObjectCollection.Add(new WrapData() { TaskId = 4905, TaskName = "Phase 3 complete", StartDate = new DateTime(2025, 12, 19), EndDate = new DateTime(2025, 12, 20), Duration = 2, Priority = "Critical", Progress = "Open", Resources = 5, ParentId = 4899, Approved = false }); return BusinessObjectCollection; } } @@ -193,7 +255,7 @@ The following example demonstrates how to render a **NumericTextBox** component