diff --git a/blazor/treegrid/aggregate.md b/blazor/treegrid/aggregate.md index ba50564654..731ab4ad79 100644 --- a/blazor/treegrid/aggregate.md +++ b/blazor/treegrid/aggregate.md @@ -98,19 +98,19 @@ namespace TreeGridComponent.Data { public class TreeData { - public int TaskId { get; set; } - public string TaskName { get; set; } - public DateTime? StartDate { get; set; } - public int? Duration { get; set; } - public int? Progress { get; set; } - public bool Approved { get; set; } - public int? ParentId { get; set; } + public int TaskId { get; set; } + public string TaskName { get; set; } + public DateTime? StartDate { get; set; } + public int? Duration { get; set; } + public int? Progress { get; set; } + public bool Approved { get; set; } + public int? ParentId { get; set; } public static List GetSelfDataSource() { List TreeDataCollection = new List(); TreeDataCollection.Add(new TreeData() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, Approved = true, ParentId = null }); - TreeDataCollection.Add(new TreeData() { TaskId = 2, TaskName = "Child task 1", Duration = 4, Progress = 80, Approved = false, Duration = 50, ParentId = 1 }); + TreeDataCollection.Add(new TreeData() { TaskId = 2, TaskName = "Child task 1", Duration = 4, Progress = 80, Approved = false, ParentId = 1 }); TreeDataCollection.Add(new TreeData() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, Approved = true, ParentId = 2 }); TreeDataCollection.Add(new TreeData() { TaskId = 4, TaskName = "Child task 3", Duration = 6, Approved = false, Progress = 77, ParentId = 3 }); TreeDataCollection.Add(new TreeData() { TaskId = 5, TaskName = "Parent Task 2", Duration = 10, Progress = 70, Approved = true, ParentId = null }); @@ -172,8 +172,6 @@ The aggregate value result can be formatted by using the [Format](https://help.s @code{ public List TreeGridData { get; set; } - public Syncfusion.Blazor.Grids.AggregateTemplateContext model = new Syncfusion.Blazor.Grids.AggregateTemplateContext(); - protected override void OnInitialized() { this.TreeGridData = TreeData.GetSelfDataSource().ToList(); @@ -188,19 +186,19 @@ namespace TreeGridComponent.Data { public class TreeData { - public int TaskId { get; set; } - public string TaskName { get; set; } - public DateTime? StartDate { get; set; } - public int? Duration { get; set; } - public int? Progress { get; set; } - public bool Approved { get; set; } - public int? ParentId { get; set; } + public int TaskId { get; set; } + public string TaskName { get; set; } + public DateTime? StartDate { get; set; } + public int? Duration { get; set; } + public int? Progress { get; set; } + public bool Approved { get; set; } + public int? ParentId { get; set; } public static List GetSelfDataSource() { List TreeDataCollection = new List(); TreeDataCollection.Add(new TreeData() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, Approved = true, ParentId = null }); - TreeDataCollection.Add(new TreeData() { TaskId = 2, TaskName = "Child task 1",Duration = 4, Progress = 80, Approved = false, Duration = 50, ParentId = 1 }); + TreeDataCollection.Add(new TreeData() { TaskId = 2, TaskName = "Child task 1",Duration = 4, Progress = 80, Approved = false, ParentId = 1 }); TreeDataCollection.Add(new TreeData() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, Approved = true, ParentId = 2 }); TreeDataCollection.Add(new TreeData() { TaskId = 4, TaskName = "Child task 3", Duration = 6, Approved = false, Progress = 77, ParentId = 3 }); TreeDataCollection.Add(new TreeData() { TaskId = 5, TaskName = "Parent Task 2", Duration = 10, Progress = 70, Approved = true, ParentId = null }); diff --git a/blazor/treegrid/cell.md b/blazor/treegrid/cell.md index d4dc87fccf..b65e0c380d 100644 --- a/blazor/treegrid/cell.md +++ b/blazor/treegrid/cell.md @@ -83,6 +83,7 @@ The appearance of cells can be customized by using the [QueryCellInfo](https://h @using TreeGridComponent.Data; @using Syncfusion.Blazor.TreeGrid; +@using Syncfusion.Blazor.Grids; @@ -121,12 +122,12 @@ The appearance of cells can be customized by using the [QueryCellInfo](https://h { String[] s1 = new String[1] { "intro" }; Args.Cell.AddClass(s1); - } + } else if (Args.Column.Field == "Progress" && Args.Data.Progress > 20) { String[] s2 = new String[1] { "intro1" }; Args.Cell.AddClass(s2); - } + } } } diff --git a/blazor/treegrid/clipboard.md b/blazor/treegrid/clipboard.md index 8391f40e3e..2800a5a696 100644 --- a/blazor/treegrid/clipboard.md +++ b/blazor/treegrid/clipboard.md @@ -25,10 +25,10 @@ Interaction keys |Description @using TreeGridComponent.Data; @using Syncfusion.Blazor.TreeGrid; - + - + @@ -37,14 +37,14 @@ ParentIdMapping="ParentID" TreeColumnIndex="1"> - + @code { public List TreeData { get; set; } protected override void OnInitialized() { - this.TreeGridData = BusinessObject.GetSelfDataSource().ToList(); + this.TreeData = BusinessObject.GetSelfDataSource().ToList(); } } @@ -101,7 +101,7 @@ To copy the data of the selected rows or cells into the clipboard with help of e Copy With Header - + @@ -118,15 +118,15 @@ To copy the data of the selected rows or cells into the clipboard with help of e public List TreeData { get; set; } protected override void OnInitialized() { - this.TreeGridData = BusinessObject.GetSelfDataSource().ToList(); + this.TreeData = BusinessObject.GetSelfDataSource().ToList(); } - public async void Copy() + public async Task Copy() { await this.TreeGrid.CopyAsync(); } - public async void CopyHeader() + public async Task CopyHeader() { await this.TreeGrid.CopyAsync(true); } @@ -206,25 +206,26 @@ Tree Grid provides support for a set of copy modes with [CopyHierarchyMode](http @using TreeGridComponent.Data; @using Syncfusion.Blazor.TreeGrid; @using Syncfusion.Blazor.DropDowns; +@using Syncfusion.Blazor.Grids - + - + - + - + @code { - SfTreeGrids TreeGrid; + SfTreeGrid TreeGrid; public string CopyMode { get; set; } = "Parent"; @@ -251,7 +252,7 @@ Tree Grid provides support for a set of copy modes with [CopyHierarchyMode](http this.CopyModes.Add(new DropdownData() { Id = "None", Mode = "None" }); } - private async void OnTypeChange(Syncfusion.Blazor.DropDowns.ChangeEventArgs Args) + private async Task OnTypeChange(Syncfusion.Blazor.DropDowns.ChangeEventArgs Args) { if (Args.Value == "Parent") { diff --git a/blazor/treegrid/columns.md b/blazor/treegrid/columns.md index 194928a47c..a185e92b97 100644 --- a/blazor/treegrid/columns.md +++ b/blazor/treegrid/columns.md @@ -162,7 +162,7 @@ Customize the header element using the [HeaderTemplate](https://help.syncfusion. - + @@ -203,9 +203,10 @@ Customize the header element using the [HeaderTemplate](https://help.syncfusion. {% highlight c# %} -namespace TreeGridComponent.Data { +namespace TreeGridComponent.Data +{ -public class Employee + public class Employee { public string Name { get; set; } public string? FullName { get; set; } @@ -215,16 +216,17 @@ public class Employee public string? Country { get; set; } public int? ParentId { get; set; } public Employee Treedata { get; set; } + public int EmployeeID { get; set; } public static List GetTemplateData() { List DataCollection = new List(); - DataCollection.Add(new Employee { Name = "Robert King",Designation = "Chief Executive Officer",EmpID = "EMP001",Country = "USA",ParentId = null,Treedata = new TreeData() { ID = 21}}); - DataCollection.Add(new Employee { Name = "David william",Designation = "Vice President",EmpID = "EMP004",Country = "USA",ParentId = 1,Treedata = new TreeData() { ID = 21 }}); - DataCollection.Add(new Employee { Name = "Nancy Davolio",Designation = "Marketing Executive",EmpID = "EMP035",Country = "USA",ParentId = 1,Treedata = new TreeData() { ID = 21 }}); - DataCollection.Add(new Employee { Name = "Andrew Fuller",Designation = "Sales Representative",EmpID = "EMP045",Country = "UK",ParentId = 1,Treedata = new TreeData() { ID = 21 }}); - DataCollection.Add(new Employee { Name = "Anne Dodsworth",FullName = "AnneDodsworth",Designation = "Sales Representative",EmployeeID = 5,EmpID = "EMP091",Country = "USA",ParentId = null,Treedata = new TreeData() { ID = 21 }}); - DataCollection.Add(new Employee { Name = "Michael Suyama",FullName = "MichaelSuyama",Designation = "Sales Representative",EmployeeID = 6,EmpID = "EMP110",Country = "UK",ParentId = 5,Treedata = new TreeData() { ID = 21 }}); + DataCollection.Add(new Employee { Name = "Robert King", Designation = "Chief Executive Officer", EmployeeID= 1, EmpID = "EMP001", Country = "USA", ParentId = null}); + DataCollection.Add(new Employee { Name = "David william", Designation = "Vice President", EmployeeID = 2, EmpID = "EMP004", Country = "USA", ParentId = 1 }); + DataCollection.Add(new Employee { Name = "Nancy Davolio", Designation = "Marketing Executive", EmployeeID= 3, EmpID = "EMP035", Country = "USA", ParentId = 1 }); + DataCollection.Add(new Employee { Name = "Andrew Fuller", Designation = "Sales Representative", EmployeeID = 4,EmpID = "EMP045", Country = "UK", ParentId = 1}); + DataCollection.Add(new Employee { Name = "Anne Dodsworth", FullName = "AnneDodsworth", Designation = "Sales Representative", EmployeeID = 5, EmpID = "EMP091", Country = "USA", ParentId = null }); + DataCollection.Add(new Employee { Name = "Michael Suyama", FullName = "MichaelSuyama", Designation = "Sales Representative", EmployeeID = 6, EmpID = "EMP110", Country = "UK", ParentId = 5 }); return DataCollection; } } diff --git a/blazor/treegrid/columns/column-chooser.md b/blazor/treegrid/columns/column-chooser.md index efca5113ba..5e3867f6ea 100644 --- a/blazor/treegrid/columns/column-chooser.md +++ b/blazor/treegrid/columns/column-chooser.md @@ -255,7 +255,6 @@ Below example demonstrates simple column chooser template using [TreeGridColumnC @using Syncfusion.Blazor.Buttons @using Syncfusion.Blazor.Grids @using Syncfusion.Blazor.TreeGrid; -@inject WeatherForecastService ForecastService @@ -296,7 +295,7 @@ Below example demonstrates simple column chooser template using [TreeGridColumnC private List GridData; protected override void OnInitialized() { - GridData = ForecastService.GetTree1(); + GridData = new BusinessObject().GetTree1(); } } @@ -314,23 +313,24 @@ namespace TreeGridComponent.Data public int Progress { get; set; } public string Priority { get; set; } public int? ParentId { get; set; } - } - public List TreeGridData = new List(); - public List GetTree1() - { - if (TreeGridData.Count == 0) + + public List TreeGridData = new List(); + public List GetTree1() { - TreeGridData.Add(new BusinessObject() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, ParentId = null, Priority = "High" }); - TreeGridData.Add(new BusinessObject() { TaskId = 2, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 1, Priority = "Normal" }); - TreeGridData.Add(new BusinessObject() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 1, Priority = "Critical" }); - TreeGridData.Add(new BusinessObject() { TaskId = 4, TaskName = "Parent Task 2", Duration = 6, Progress = 77, ParentId = null, Priority = "Low" }); - TreeGridData.Add(new BusinessObject() { TaskId = 5, TaskName = "Child Task 5", Duration = 9, Progress = 25, ParentId = 4, Priority = "Normal" }); - TreeGridData.Add(new BusinessObject() { TaskId = 6, TaskName = "Child Task 6", Duration = 9, Progress = 7, ParentId = 5, Priority = "Normal" }); - TreeGridData.Add(new BusinessObject() { TaskId = 7, TaskName = "Parent Task 3", Duration = 4, Progress = 45, ParentId = null, Priority = "High" }); - TreeGridData.Add(new BusinessObject() { TaskId = 8, TaskName = "Child Task 7", Duration = 3, Progress = 38, ParentId = 7, Priority = "Critical" }); - TreeGridData.Add(new BusinessObject() { TaskId = 9, TaskName = "Child Task 8", Duration = 7, Progress = 70, ParentId = 7, Priority = "Low" }); + if (TreeGridData.Count == 0) + { + TreeGridData.Add(new BusinessObject() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, ParentId = null, Priority = "High" }); + TreeGridData.Add(new BusinessObject() { TaskId = 2, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 1, Priority = "Normal" }); + TreeGridData.Add(new BusinessObject() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 1, Priority = "Critical" }); + TreeGridData.Add(new BusinessObject() { TaskId = 4, TaskName = "Parent Task 2", Duration = 6, Progress = 77, ParentId = null, Priority = "Low" }); + TreeGridData.Add(new BusinessObject() { TaskId = 5, TaskName = "Child Task 5", Duration = 9, Progress = 25, ParentId = 4, Priority = "Normal" }); + TreeGridData.Add(new BusinessObject() { TaskId = 6, TaskName = "Child Task 6", Duration = 9, Progress = 7, ParentId = 5, Priority = "Normal" }); + TreeGridData.Add(new BusinessObject() { TaskId = 7, TaskName = "Parent Task 3", Duration = 4, Progress = 45, ParentId = null, Priority = "High" }); + TreeGridData.Add(new BusinessObject() { TaskId = 8, TaskName = "Child Task 7", Duration = 3, Progress = 38, ParentId = 7, Priority = "Critical" }); + TreeGridData.Add(new BusinessObject() { TaskId = 9, TaskName = "Child Task 8", Duration = 7, Progress = 70, ParentId = 7, Priority = "Low" }); + } + return TreeGridData; } - return TreeGridData; } } @@ -350,18 +350,19 @@ In below example, we have rendered ListView as custom component inside the Templ @using TreeGridComponent.Data; @using Syncfusion.Blazor.TreeGrid; -@inject WeatherForecastService ForecastService +@using Syncfusion.Blazor.Grids; + + TreeColumnIndex="1" ShowColumnChooser="true" Toolbar="@(new List(){ "ColumnChooser" })" AllowPaging="true"> - - + + @@ -398,8 +399,8 @@ In below example, we have rendered ListView as custom component inside the Templ public SfTreeGrid TreeGrid { get; set; } private List GridData; protected override void OnInitialized() - { - GridData = ForecastService.GetTree1(); + { + GridData = new BusinessObject().GetTree1(); } } @@ -417,23 +418,24 @@ namespace TreeGridComponent.Data public int Progress { get; set; } public string Priority { get; set; } public int? ParentId { get; set; } - } - public List TreeGridData = new List(); - public List GetTree1() - { - if (TreeGridData.Count == 0) + + public List TreeGridData = new List(); + public List GetTree1() { - TreeGridData.Add(new BusinessObject() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, ParentId = null, Priority = "High" }); - TreeGridData.Add(new BusinessObject() { TaskId = 2, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 1, Priority = "Normal" }); - TreeGridData.Add(new BusinessObject() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 1, Priority = "Critical" }); - TreeGridData.Add(new BusinessObject() { TaskId = 4, TaskName = "Parent Task 2", Duration = 6, Progress = 77, ParentId = null, Priority = "Low" }); - TreeGridData.Add(new BusinessObject() { TaskId = 5, TaskName = "Child Task 5", Duration = 9, Progress = 25, ParentId = 4, Priority = "Normal" }); - TreeGridData.Add(new BusinessObject() { TaskId = 6, TaskName = "Child Task 6", Duration = 9, Progress = 7, ParentId = 5, Priority = "Normal" }); - TreeGridData.Add(new BusinessObject() { TaskId = 7, TaskName = "Parent Task 3", Duration = 4, Progress = 45, ParentId = null, Priority = "High" }); - TreeGridData.Add(new BusinessObject() { TaskId = 8, TaskName = "Child Task 7", Duration = 3, Progress = 38, ParentId = 7, Priority = "Critical" }); - TreeGridData.Add(new BusinessObject() { TaskId = 9, TaskName = "Child Task 8", Duration = 7, Progress = 70, ParentId = 7, Priority = "Low" }); + if (TreeGridData.Count == 0) + { + TreeGridData.Add(new BusinessObject() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, ParentId = null, Priority = "High" }); + TreeGridData.Add(new BusinessObject() { TaskId = 2, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 1, Priority = "Normal" }); + TreeGridData.Add(new BusinessObject() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 1, Priority = "Critical" }); + TreeGridData.Add(new BusinessObject() { TaskId = 4, TaskName = "Parent Task 2", Duration = 6, Progress = 77, ParentId = null, Priority = "Low" }); + TreeGridData.Add(new BusinessObject() { TaskId = 5, TaskName = "Child Task 5", Duration = 9, Progress = 25, ParentId = 4, Priority = "Normal" }); + TreeGridData.Add(new BusinessObject() { TaskId = 6, TaskName = "Child Task 6", Duration = 9, Progress = 7, ParentId = 5, Priority = "Normal" }); + TreeGridData.Add(new BusinessObject() { TaskId = 7, TaskName = "Parent Task 3", Duration = 4, Progress = 45, ParentId = null, Priority = "High" }); + TreeGridData.Add(new BusinessObject() { TaskId = 8, TaskName = "Child Task 7", Duration = 3, Progress = 38, ParentId = 7, Priority = "Critical" }); + TreeGridData.Add(new BusinessObject() { TaskId = 9, TaskName = "Child Task 8", Duration = 7, Progress = 70, ParentId = 7, Priority = "Low" }); + } + return TreeGridData; } - return TreeGridData; } } @@ -449,8 +451,8 @@ namespace TreeGridComponent.Data @using Syncfusion.Blazor.TreeGrid @using Syncfusion.Blazor.Lists; @using Syncfusion.Blazor.Inputs; +@using TreeGridComponent.Data @inject Microsoft.AspNetCore.Components.NavigationManager UriHelper -@inject WeatherForecastService ForecastService
@@ -462,7 +464,7 @@ namespace TreeGridComponent.Data @@ -577,7 +579,7 @@ We can also group the columns inside the column chooser template with the help o @using TreeGridComponent.Data; @using Syncfusion.Blazor.TreeGrid; -@inject WeatherForecastService ForecastService +@using Syncfusion.Blazor.Grids; @@ -626,7 +628,7 @@ We can also group the columns inside the column chooser template with the help o private List GridData; protected override void OnInitialized() { - GridData = ForecastService.GetTree1(); + GridData = new BusinessObject().GetTree1(); } } @@ -644,23 +646,24 @@ namespace TreeGridComponent.Data public int Progress { get; set; } public string Priority { get; set; } public int? ParentId { get; set; } - } - public List TreeGridData = new List(); - public List GetTree1() - { - if (TreeGridData.Count == 0) + + public List TreeGridData = new List(); + public List GetTree1() { - TreeGridData.Add(new BusinessObject() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, ParentId = null, Priority = "High" }); - TreeGridData.Add(new BusinessObject() { TaskId = 2, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 1, Priority = "Normal" }); - TreeGridData.Add(new BusinessObject() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 1, Priority = "Critical" }); - TreeGridData.Add(new BusinessObject() { TaskId = 4, TaskName = "Parent Task 2", Duration = 6, Progress = 77, ParentId = null, Priority = "Low" }); - TreeGridData.Add(new BusinessObject() { TaskId = 5, TaskName = "Child Task 5", Duration = 9, Progress = 25, ParentId = 4, Priority = "Normal" }); - TreeGridData.Add(new BusinessObject() { TaskId = 6, TaskName = "Child Task 6", Duration = 9, Progress = 7, ParentId = 5, Priority = "Normal" }); - TreeGridData.Add(new BusinessObject() { TaskId = 7, TaskName = "Parent Task 3", Duration = 4, Progress = 45, ParentId = null, Priority = "High" }); - TreeGridData.Add(new BusinessObject() { TaskId = 8, TaskName = "Child Task 7", Duration = 3, Progress = 38, ParentId = 7, Priority = "Critical" }); - TreeGridData.Add(new BusinessObject() { TaskId = 9, TaskName = "Child Task 8", Duration = 7, Progress = 70, ParentId = 7, Priority = "Low" }); + if (TreeGridData.Count == 0) + { + TreeGridData.Add(new BusinessObject() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, ParentId = null, Priority = "High" }); + TreeGridData.Add(new BusinessObject() { TaskId = 2, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 1, Priority = "Normal" }); + TreeGridData.Add(new BusinessObject() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 1, Priority = "Critical" }); + TreeGridData.Add(new BusinessObject() { TaskId = 4, TaskName = "Parent Task 2", Duration = 6, Progress = 77, ParentId = null, Priority = "Low" }); + TreeGridData.Add(new BusinessObject() { TaskId = 5, TaskName = "Child Task 5", Duration = 9, Progress = 25, ParentId = 4, Priority = "Normal" }); + TreeGridData.Add(new BusinessObject() { TaskId = 6, TaskName = "Child Task 6", Duration = 9, Progress = 7, ParentId = 5, Priority = "Normal" }); + TreeGridData.Add(new BusinessObject() { TaskId = 7, TaskName = "Parent Task 3", Duration = 4, Progress = 45, ParentId = null, Priority = "High" }); + TreeGridData.Add(new BusinessObject() { TaskId = 8, TaskName = "Child Task 7", Duration = 3, Progress = 38, ParentId = 7, Priority = "Critical" }); + TreeGridData.Add(new BusinessObject() { TaskId = 9, TaskName = "Child Task 8", Duration = 7, Progress = 70, ParentId = 7, Priority = "Low" }); + } + return TreeGridData; } - return TreeGridData; } } diff --git a/blazor/treegrid/columns/column-menu.md b/blazor/treegrid/columns/column-menu.md index 6b8df111a0..31ece1c5cf 100644 --- a/blazor/treegrid/columns/column-menu.md +++ b/blazor/treegrid/columns/column-menu.md @@ -23,59 +23,62 @@ The default items are displayed in the following table. {% tabs %} -{% highlight razor %} +{% highlight razor tabtitle="Index.razor" %} -@using TreeGridComponent.Data; -@using Syncfusion.Blazor.TreeGrid; +@using Syncfusion.Blazor.TreeGrid +@using TreeGridComponent.Data - - + + - - - - + + + + -@code{ +@code { public List TreeGridData { get; set; } + protected override void OnInitialized() { - this.TreeGridData = TreeData.GetSelfDataSource().ToList(); + TreeGridData = TreeData.GetSelfDataSource().ToList(); } } {% endhighlight %} -{% highlight c# %} - -namespace TreeGridComponent.Data { +{% highlight c# tabtitle="TreeData.cs" %} -public class TreeData +namespace TreeGridComponent.Data +{ + public class TreeData { public class BusinessObject { - public int TaskId { get; set;} - public string TaskName { get; set;} - public int? Duration { get; set;} - public int? Progress { get; set;} - public int? ParentId { get; set;} + public int TaskId { get; set; } + public string TaskName { get; set; } + public int? Duration { get; set; } + public int? Progress { get; set; } + public int? ParentId { get; set; } } public static List GetSelfDataSource() { - List BusinessObjectCollection = new List(); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1,TaskName = "Parent Task 1",Duration = 10,Progress = 70,ParentId = null }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2,TaskName = "Child task 1",Duration = 4,Progress = 80,ParentId = 1 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3,TaskName = "Child Task 2",Duration = 5,Progress = 65,ParentId = 2 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4,TaskName = "Child task 3",Duration = 6,Progress = 77,ParentId = 3 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5,TaskName = "Parent Task 2",Duration = 10,Progress = 70,ParentId = null}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6,TaskName = "Child task 1",Duration = 4,Progress = 80,ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7,TaskName = "Child Task 2",Duration = 5,Progress = 65,ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8,TaskName = "Child task 3",Duration = 6,Progress = 77,ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9,TaskName = "Child task 4",Duration = 6,Progress = 77,ParentId = 5}); + List BusinessObjectCollection = new List + { + new BusinessObject() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, ParentId = null }, + new BusinessObject() { TaskId = 2, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 1 }, + new BusinessObject() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 2 }, + new BusinessObject() { TaskId = 4, TaskName = "Child task 3", Duration = 6, Progress = 77, ParentId = 3 }, + new BusinessObject() { TaskId = 5, TaskName = "Parent Task 2", Duration = 10, Progress = 70, ParentId = null }, + new BusinessObject() { TaskId = 6, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 5 }, + new BusinessObject() { TaskId = 7, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 5 }, + new BusinessObject() { TaskId = 8, TaskName = "Child task 3", Duration = 6, Progress = 77, ParentId = 5 }, + new BusinessObject() { TaskId = 9, TaskName = "Child task 4", Duration = 6, Progress = 77, ParentId = 5 } + }; + return BusinessObjectCollection; } } diff --git a/blazor/treegrid/columns/column-reorder.md b/blazor/treegrid/columns/column-reorder.md index dec060007a..f04e52fbcd 100644 --- a/blazor/treegrid/columns/column-reorder.md +++ b/blazor/treegrid/columns/column-reorder.md @@ -13,57 +13,61 @@ Reordering can be done by drag and drop of a particular column header from one i {% tabs %} -{% highlight razor %} +{% highlight razor tabtitle="Index.razor" %} -@using TreeGridComponent.Data; -@using Syncfusion.Blazor.TreeGrid; +@using Syncfusion.Blazor.TreeGrid +@using TreeGridComponent.Data - - - - + + + + -@code{ +@code { public List TreeGridData { get; set; } + protected override void OnInitialized() { - this.TreeGridData = TreeData.GetSelfDataSource().ToList(); + TreeGridData = TreeData.GetSelfDataSource().ToList(); } } {% endhighlight %} -{% highlight c# %} +{% highlight c# tabtitle="TreeData.cs" %} -namespace TreeGridComponent.Data { - -public class TreeData +namespace TreeGridComponent.Data +{ + public class TreeData { public class BusinessObject { - public int TaskId { get; set;} - public string TaskName { get; set;} - public int? Duration { get; set;} - public int? Progress { get; set;} - public int? ParentId { get; set;} + public int TaskId { get; set; } + public string TaskName { get; set; } + public int? Duration { get; set; } + public int? Progress { get; set; } + public int? ParentId { get; set; } } public static List GetSelfDataSource() { - List BusinessObjectCollection = new List(); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1,TaskName = "Parent Task 1",Duration = 10,Progress = 70,ParentId = null }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2,TaskName = "Child task 1",Duration = 4,Progress = 80,ParentId = 1 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3,TaskName = "Child Task 2",Duration = 5,Progress = 65,ParentId = 2 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4,TaskName = "Child task 3",Duration = 6,Progress = 77,ParentId = 3 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5,TaskName = "Parent Task 2",Duration = 10,Progress = 70,ParentId = null}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6,TaskName = "Child task 1",Duration = 4,Progress = 80,ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7,TaskName = "Child Task 2",Duration = 5,Progress = 65,ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8,TaskName = "Child task 3",Duration = 6,Progress = 77,ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9,TaskName = "Child task 4",Duration = 6,Progress = 77,ParentId = 5}); + List BusinessObjectCollection = new List + { + new BusinessObject() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, ParentId = null }, + new BusinessObject() { TaskId = 2, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 1 }, + new BusinessObject() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 2 }, + new BusinessObject() { TaskId = 4, TaskName = "Child task 3", Duration = 6, Progress = 77, ParentId = 3 }, + new BusinessObject() { TaskId = 5, TaskName = "Parent Task 2", Duration = 10, Progress = 70, ParentId = null }, + new BusinessObject() { TaskId = 6, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 5 }, + new BusinessObject() { TaskId = 7, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 5 }, + new BusinessObject() { TaskId = 8, TaskName = "Child task 3", Duration = 6, Progress = 77, ParentId = 5 }, + new BusinessObject() { TaskId = 9, TaskName = "Child task 4", Duration = 6, Progress = 77, ParentId = 5 } + }; + return BusinessObjectCollection; } } @@ -86,30 +90,23 @@ Tree Grid has option to reorder a column either by interaction or by using the [ {% highlight razor %} @using TreeGridComponent.Data; -@using Syncfusion.Blazor.Buttons; @using Syncfusion.Blazor.TreeGrid; - - + - + @code{ - private SfTreeGrid TreeGrid; public List TreeGridData { get; set; } protected override void OnInitialized() { this.TreeGridData = TreeData.GetSelfDataSource().ToList(); } - private async Task ReorderColumn() - { - await TreeGrid.ReorderColumnsAsync(new List(){ "TaskName" }, "Duration"); - } } {% endhighlight %} diff --git a/blazor/treegrid/columns/column-resizing.md b/blazor/treegrid/columns/column-resizing.md index e68192c50d..07c30aec62 100644 --- a/blazor/treegrid/columns/column-resizing.md +++ b/blazor/treegrid/columns/column-resizing.md @@ -13,62 +13,60 @@ Column width can be resized by clicking and dragging the right edge of the colum {% tabs %} -{% highlight razor %} +{% highlight razor tabtitle="Index.razor" %} +@using Syncfusion.Blazor.TreeGrid -@using TreeGridComponent.Data; -@using Syncfusion.Blazor.TreeGrid; - - + - - + + -@code{ +@code { public List TreeGridData { get; set; } + protected override void OnInitialized() { - this.TreeGridData = TreeData.GetSelfDataSource().ToList(); + TreeGridData = TreeData.GetSelfDataSource().ToList(); } } - {% endhighlight %} - -{% highlight c# %} - -namespace TreeGridComponent.Data { - -public class TreeData +{% highlight c# tabtitle="TreeData.cs" %} +namespace TreeGridComponent.Data +{ + public class TreeData { public class BusinessObject { - public int TaskId { get; set;} - public string TaskName { get; set;} - public int? Duration { get; set;} - public int? Progress { get; set;} - public int? ParentId { get; set;} + public int TaskId { get; set; } + public string TaskName { get; set; } + public int? Duration { get; set; } + public int? Progress { get; set; } + public int? ParentId { get; set; } } public static List GetSelfDataSource() { - List BusinessObjectCollection = new List(); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1,TaskName = "Parent Task 1",Duration = 10,Progress = 70,ParentId = null }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2,TaskName = "Child task 1",Duration = 4,Progress = 80,ParentId = 1 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3,TaskName = "Child Task 2",Duration = 5,Progress = 65,ParentId = 2 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4,TaskName = "Child task 3",Duration = 6,Progress = 77,ParentId = 3 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5,TaskName = "Parent Task 2",Duration = 10,Progress = 70,ParentId = null}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6,TaskName = "Child task 1",Duration = 4,Progress = 80,ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7,TaskName = "Child Task 2",Duration = 5,Progress = 65,ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8,TaskName = "Child task 3",Duration = 6,Progress = 77,ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9,TaskName = "Child task 4",Duration = 6,Progress = 77,ParentId = 5}); + List BusinessObjectCollection = new List + { + new BusinessObject() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, ParentId = null }, + new BusinessObject() { TaskId = 2, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 1 }, + new BusinessObject() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 2 }, + new BusinessObject() { TaskId = 4, TaskName = "Child task 3", Duration = 6, Progress = 77, ParentId = 3 }, + new BusinessObject() { TaskId = 5, TaskName = "Parent Task 2", Duration = 10, Progress = 70, ParentId = null }, + new BusinessObject() { TaskId = 6, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 5 }, + new BusinessObject() { TaskId = 7, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 5 }, + new BusinessObject() { TaskId = 8, TaskName = "Child task 3", Duration = 6, Progress = 77, ParentId = 5 }, + new BusinessObject() { TaskId = 9, TaskName = "Child task 4", Duration = 6, Progress = 77, ParentId = 5 } + }; + return BusinessObjectCollection; } } } - {% endhighlight %} {% endtabs %} @@ -86,62 +84,64 @@ In the following sample, minimum and maximum width are defined for **TaskName** {% tabs %} -{% highlight razor %} +{% highlight razor tabtitle="Index.razor" %} -@using TreeGridComponent.Data; -@using Syncfusion.Blazor.TreeGrid; +@using Syncfusion.Blazor.TreeGrid - + - + - - + + -@code{ +@code { public List TreeGridData { get; set; } + protected override void OnInitialized() { - this.TreeGridData = TreeData.GetSelfDataSource().ToList(); + TreeGridData = TreeData.GetSelfDataSource().ToList(); } } {% endhighlight %} -{% highlight c# %} - -namespace TreeGridComponent.Data { +{% highlight c# tabtitle="TreeData.cs" %} -public class TreeData +namespace TreeGridComponent.Data +{ + public class TreeData { public class BusinessObject { - public int TaskId { get; set;} - public string TaskName { get; set;} - public int? Duration { get; set;} - public int? Progress { get; set;} - public int? ParentId { get; set;} + public int TaskId { get; set; } + public string TaskName { get; set; } + public int? Duration { get; set; } + public int? Progress { get; set; } + public int? ParentId { get; set; } } public static List GetSelfDataSource() { - List BusinessObjectCollection = new List(); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1,TaskName = "Parent Task 1",Duration = 10,Progress = 70,ParentId = null }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2,TaskName = "Child task 1",Duration = 4,Progress = 80,ParentId = 1 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3,TaskName = "Child Task 2",Duration = 5,Progress = 65,ParentId = 2 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4,TaskName = "Child task 3",Duration = 6,Progress = 77,ParentId = 3 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5,TaskName = "Parent Task 2",Duration = 10,Progress = 70,ParentId = null}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6,TaskName = "Child task 1",Duration = 4,Progress = 80,ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7,TaskName = "Child Task 2",Duration = 5,Progress = 65,ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8,TaskName = "Child task 3",Duration = 6,Progress = 77,ParentId = 5}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9,TaskName = "Child task 4",Duration = 6,Progress = 77,ParentId = 5}); + List BusinessObjectCollection = new List + { + new BusinessObject() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, ParentId = null }, + new BusinessObject() { TaskId = 2, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 1 }, + new BusinessObject() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 2 }, + new BusinessObject() { TaskId = 4, TaskName = "Child task 3", Duration = 6, Progress = 77, ParentId = 3 }, + new BusinessObject() { TaskId = 5, TaskName = "Parent Task 2", Duration = 10, Progress = 70, ParentId = null }, + new BusinessObject() { TaskId = 6, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 5 }, + new BusinessObject() { TaskId = 7, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 5 }, + new BusinessObject() { TaskId = 8, TaskName = "Child task 3", Duration = 6, Progress = 77, ParentId = 5 }, + new BusinessObject() { TaskId = 9, TaskName = "Child task 4", Duration = 6, Progress = 77, ParentId = 5 } + }; + return BusinessObjectCollection; } } } - {% endhighlight %} {% endtabs %} @@ -152,10 +152,9 @@ Stacked columns can be resized by clicking and dragging the right edge of the st {% tabs %} -{% highlight razor %} +{% highlight razor tabtitle="Index.razor" %} -@using TreeGridComponent.Data; -@using Syncfusion.Blazor.TreeGrid; +@using Syncfusion.Blazor.TreeGrid @@ -175,63 +174,65 @@ Stacked columns can be resized by clicking and dragging the right edge of the st - + - + -@code{ +@code { public List TreeGridData { get; set; } + protected override void OnInitialized() { - this.TreeGridData = ShipmentData.GetShipmentData().ToList(); + TreeGridData = ShipmentData.GetShipmentData().ToList(); } } {% endhighlight %} -{% highlight c# %} - -namespace TreeGridComponent.Data { +{% highlight c# tabtitle="ShipmentData.cs" %} -public class ShipmentData +namespace TreeGridComponent.Data { - public int 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 int? ParentID { get; set; } - public string ShipmentCategory { get; set; } - public DateTime ShippedDate { get; set; } - public DateTime OrderDate { get; set; } - public List Children { get; set; } - - public static List GetShipmentData() + public class ShipmentData { - List DataCollection = new List() { - - new ShipmentData() { ID = 1,Name = "Order 1",Category = "Seafood",Units = 1395,UnitPrice = 47,Price = 65565,ParentID = null,OrderDate = new DateTime(2017, 3, 2),ShippedDate = new DateTime(2017, 9, 2),ShipmentCategory = "Seafood"}, - new ShipmentData() { ID = 11,Name = "Mackerel",Category = "Frozen Seafood",Units = 235,UnitPrice = 12,Price = 2820,ParentID = 1,OrderDate = new DateTime(2017, 3, 3),ShippedDate = new DateTime(2017, 10, 3),ShipmentCategory = "Frozen Seafood"}, - new ShipmentData() { ID = 12,Name = "Yellowfin Tuna",Category = "Frozen Seafood",Units = 324,UnitPrice = 8,Price = 2592,ParentID = 1,OrderDate = new DateTime(2017, 3, 5),ShippedDate = new DateTime(2017, 10, 5),ShipmentCategory = "Frozen Seafood"}, - new ShipmentData() { ID = 13,Name = "Herrings",Category = "Frozen Seafood",Units = 488,UnitPrice = 11,Price = 5368,ParentID = 1,OrderDate = new DateTime(2017, 8, 5),ShippedDate = new DateTime(2017, 5, 15),ShipmentCategory = "Frozen Seafood"}, - new ShipmentData() { ID = 14,Name = "Preserved Olives",Category = "Edible",Units = 125,UnitPrice = 9,Price = 1125,ParentID = 1,OrderDate = new DateTime(2017, 6, 10),ShippedDate = new DateTime(2017, 6, 17),ShipmentCategory = "Edible"}, - new ShipmentData() { ID = 15,Name = " Sweet corn Frozen ",Category = "Edible",Units = 223,UnitPrice = 7,Price = 1561,ParentID = 1,OrderDate = new DateTime(2017, 7, 12),ShippedDate = new DateTime(2017, 7, 19),ShipmentCategory = "Edible"}, - new ShipmentData() { ID = 2,Name = "Order 2",Category = "Products",Units = 1944,UnitPrice = 58,Price = 21233,ParentID = null,OrderDate = new DateTime(2017, 1, 10),ShippedDate = new DateTime(2017, 1, 16),ShipmentCategory = "Seafood",Children = new List()}, - new ShipmentData() { ID = 21,Name = "Tilapias",Category = "Frozen Seafood",Units = 278,UnitPrice = 15,Price = 4170,ParentID = 2,OrderDate = new DateTime(2017, 2, 5),ShippedDate = new DateTime(2017, 2, 12),ShipmentCategory = "Frozen Seafood"}, - new ShipmentData() { ID = 22,Name = "White Shrimp",Category = "Frozen Seafood",Units = 560,UnitPrice = 7,Price = 3920,ParentID = 2,OrderDate = new DateTime(2017, 5, 22),ShippedDate = new DateTime(2017, 5, 29),ShipmentCategory = "Frozen Seafood"}, - new ShipmentData() { ID = 23,Name = "Fresh Cheese",Category = "Dairy",Units = 323,UnitPrice = 12,Price = 3876,ParentID = 2,OrderDate = new DateTime(2017, 6, 8),ShippedDate = new DateTime(2017, 6, 15),ShipmentCategory = "Dairy"}, - new ShipmentData() { ID = 24,Name = "Blue Veined Cheese",Category = "Dairy",Units = 370,UnitPrice = 15,Price = 5550,ParentID = 2,OrderDate = new DateTime(2017, 7, 10),ShippedDate = new DateTime(2017, 7, 17),ShipmentCategory = "Dairy"}, - new ShipmentData() { ID = 25,Name = "Butter",Category = "Dairy",Units = 413,UnitPrice = 9,Price = 3717,ParentID = 2,OrderDate = new DateTime(2017, 9, 18),ShippedDate = new DateTime(2017, 9, 25),ShipmentCategory = "Dairy"} - }; - return DataCollection; + public int 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 int? ParentID { get; set; } + public string ShipmentCategory { get; set; } + public DateTime ShippedDate { get; set; } + public DateTime OrderDate { get; set; } + public List Children { get; set; } + + public static List GetShipmentData() + { + List DataCollection = new List() + { + new ShipmentData() { ID = 1, Name = "Order 1", Category = "Seafood", Units = 1395, UnitPrice = 47, Price = 65565, ParentID = null, OrderDate = new DateTime(2017, 3, 2), ShippedDate = new DateTime(2017, 9, 2), ShipmentCategory = "Seafood" }, + new ShipmentData() { ID = 11, Name = "Mackerel", Category = "Frozen Seafood", Units = 235, UnitPrice = 12, Price = 2820, ParentID = 1, OrderDate = new DateTime(2017, 3, 3), ShippedDate = new DateTime(2017, 10, 3), ShipmentCategory = "Frozen Seafood" }, + new ShipmentData() { ID = 12, Name = "Yellowfin Tuna", Category = "Frozen Seafood", Units = 324, UnitPrice = 8, Price = 2592, ParentID = 1, OrderDate = new DateTime(2017, 3, 5), ShippedDate = new DateTime(2017, 10, 5), ShipmentCategory = "Frozen Seafood" }, + new ShipmentData() { ID = 13, Name = "Herrings", Category = "Frozen Seafood", Units = 488, UnitPrice = 11, Price = 5368, ParentID = 1, OrderDate = new DateTime(2017, 8, 5), ShippedDate = new DateTime(2017, 5, 15), ShipmentCategory = "Frozen Seafood" }, + new ShipmentData() { ID = 14, Name = "Preserved Olives", Category = "Edible", Units = 125, UnitPrice = 9, Price = 1125, ParentID = 1, OrderDate = new DateTime(2017, 6, 10), ShippedDate = new DateTime(2017, 6, 17), ShipmentCategory = "Edible" }, + new ShipmentData() { ID = 15, Name = "Sweet corn Frozen", Category = "Edible", Units = 223, UnitPrice = 7, Price = 1561, ParentID = 1, OrderDate = new DateTime(2017, 7, 12), ShippedDate = new DateTime(2017, 7, 19), ShipmentCategory = "Edible" }, + new ShipmentData() { ID = 2, Name = "Order 2", Category = "Products", Units = 1944, UnitPrice = 58, Price = 21233, ParentID = null, OrderDate = new DateTime(2017, 1, 10), ShippedDate = new DateTime(2017, 1, 16), ShipmentCategory = "Seafood", Children = new List() }, + new ShipmentData() { ID = 21, Name = "Tilapias", Category = "Frozen Seafood", Units = 278, UnitPrice = 15, Price = 4170, ParentID = 2, OrderDate = new DateTime(2017, 2, 5), ShippedDate = new DateTime(2017, 2, 12), ShipmentCategory = "Frozen Seafood" }, + new ShipmentData() { ID = 22, Name = "White Shrimp", Category = "Frozen Seafood", Units = 560, UnitPrice = 7, Price = 3920, ParentID = 2, OrderDate = new DateTime(2017, 5, 22), ShippedDate = new DateTime(2017, 5, 29), ShipmentCategory = "Frozen Seafood" }, + new ShipmentData() { ID = 23, Name = "Fresh Cheese", Category = "Dairy", Units = 323, UnitPrice = 12, Price = 3876, ParentID = 2, OrderDate = new DateTime(2017, 6, 8), ShippedDate = new DateTime(2017, 6, 15), ShipmentCategory = "Dairy" }, + new ShipmentData() { ID = 24, Name = "Blue Veined Cheese", Category = "Dairy", Units = 370, UnitPrice = 15, Price = 5550, ParentID = 2, OrderDate = new DateTime(2017, 7, 10), ShippedDate = new DateTime(2017, 7, 17), ShipmentCategory = "Dairy" }, + new ShipmentData() { ID = 25, Name = "Butter", Category = "Dairy", Units = 413, UnitPrice = 9, Price = 3717, ParentID = 2, OrderDate = new DateTime(2017, 9, 18), ShippedDate = new DateTime(2017, 9, 25), ShipmentCategory = "Dairy" } + }; + + return DataCollection; + } } } -} {% endhighlight %} diff --git a/blazor/treegrid/columns/column-template.md b/blazor/treegrid/columns/column-template.md index 8aea4d5b7d..ef7f45b717 100644 --- a/blazor/treegrid/columns/column-template.md +++ b/blazor/treegrid/columns/column-template.md @@ -547,6 +547,7 @@ This can be achieved by initially defining an anchor tag inside the column templ ```cshtml @inject NavigationManager UriHelper @using Syncfusion.Blazor.TreeGrid +@using Syncfusion.Blazor.Grids diff --git a/blazor/treegrid/context-menu.md b/blazor/treegrid/context-menu.md index acafaf27d2..a25ec8e621 100644 --- a/blazor/treegrid/context-menu.md +++ b/blazor/treegrid/context-menu.md @@ -131,11 +131,11 @@ The following sample code demonstrates defining custom context menu item and its TreeData.Add(new BusinessObject() { TaskId = 9, TaskName = "Child Task 8", Duration = 778907897, Progress = 70, ParentId = 7, Priority = "Low" }); } - public void OnContextMenuClick(ContextMenuClickEventArgs args) + public async Task OnContextMenuClick(ContextMenuClickEventArgs args) { if (args.Item.Id == "copywithheader") { - this.TreeGrid.CopyAsync(true); + await this.TreeGrid.CopyAsync(true); } } } diff --git a/blazor/treegrid/custom-binding.md b/blazor/treegrid/custom-binding.md index 3d55d1bc0c..5629c3451e 100644 --- a/blazor/treegrid/custom-binding.md +++ b/blazor/treegrid/custom-binding.md @@ -107,7 +107,7 @@ The following sample code demonstrates implementing custom data binding using cu protected override void OnInitialized() { - TreeData = SelfReferenceData.GetTree().ToList(); + TreeData = new SelfReferenceData().GetTree().ToList(); } // Implementing custom adaptor by extending the DataAdaptor class @@ -495,7 +495,7 @@ The following sample code demonstrates implementing CRUD operations for the cust protected override void OnInitialized() { - TreeData = SelfReferenceData.GetTree().ToList(); + TreeData = new SelfReferenceData().GetTree().ToList(); } // Implementing custom adaptor by extending the DataAdaptor class 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 diff --git a/blazor/treegrid/editing/batch-editing.md b/blazor/treegrid/editing/batch-editing.md index 53dcf2d14e..94c135e755 100644 --- a/blazor/treegrid/editing/batch-editing.md +++ b/blazor/treegrid/editing/batch-editing.md @@ -20,7 +20,7 @@ The following example shows how to enable Batch editing, including add, edit, an @using TreeGridComponent.Data; @using Syncfusion.Blazor.TreeGrid; - + @@ -37,41 +37,39 @@ The following example shows how to enable Batch editing, including add, edit, an public List TreeData { get; set; } protected override void OnInitialized() { - this.TreeData = BusinessObject.GetSelfDataSource().ToList(); + TreeData = BusinessObject.GetSelfDataSource().ToList(); } } {% endhighlight %} -{% highlight c# %} - +{% highlight c# tabtitle="BusinessObject.cs" %} namespace TreeGridComponent.Data { - public class BusinessObject - { - public int TaskId { get; set;} - public string TaskName { get; set;} - public DateTime? StartDate { get; set;} - public int? Duration { get; set;} - public int? Progress { get; set;} - public string Priority { get; set;} - public int? ParentId { get; set;} + public class BusinessObject + { + public int TaskId { get; set; } + public string TaskName { get; set; } + public DateTime? StartDate { 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() { List BusinessObjectCollection = new List(); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1,TaskName = "Parent Task 1",StartDate = new DateTime(2017, 10, 23),Duration = 10,Progress = 70,Priority = "Critical",ParentId = null }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2,TaskName = "Child task 1",StartDate = new DateTime(2017, 10, 23),Duration = 5,Progress = 80,Priority = "Low",ParentId = 1 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3,TaskName = "Child Task 2",StartDate = new DateTime(2017, 10, 24),Duration = 5,Progress = 65,Priority = "Critical",ParentId = 2 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4,TaskName = "Child task 3",StartDate = new DateTime(2017, 10, 25),Duration = 6,Priority = "High",Progress = 77,ParentId = 3 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5, TaskName = "Child Task 5",StartDate = new DateTime(2017, 10, 26), Duration = 9, Progress = 25, ParentId = 4, Priority = "Normal" }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6, TaskName = "Child Task 6",StartDate = new DateTime(2017, 10, 27), Duration = 9, Progress = 7, ParentId = 5, Priority = "Normal" }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7, TaskName = "Parent Task 3",StartDate = new DateTime(2017, 10, 28), Duration = 4, Progress = 45, ParentId = null, Priority = "High" }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8, TaskName = "Child Task 7",StartDate = new DateTime(2017, 10, 29), Duration = 3, Progress = 38, ParentId = 7, Priority = "Critical" }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9, TaskName = "Child Task 8",StartDate = new DateTime(2017, 10, 30), Duration = 7, Progress = 70, ParentId = 7, Priority = "Low" }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1, TaskName = "Parent Task 1", StartDate = new DateTime(2017, 10, 23), Duration = 10, Progress = 70, Priority = "Critical", ParentId = null }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2, TaskName = "Child task 1", StartDate = new DateTime(2017, 10, 23), Duration = 5, Progress = 80, Priority = "Low", ParentId = 1 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3, TaskName = "Child Task 2", StartDate = new DateTime(2017, 10, 24), Duration = 5, Progress = 65, Priority = "Critical", ParentId = 2 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4, TaskName = "Child task 3", StartDate = new DateTime(2017, 10, 25), Duration = 6, Priority = "High", Progress = 77, ParentId = 3 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5, TaskName = "Child Task 5", StartDate = new DateTime(2017, 10, 26), Duration = 9, Progress = 25, ParentId = 4, Priority = "Normal" }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6, TaskName = "Child Task 6", StartDate = new DateTime(2017, 10, 27), Duration = 9, Progress = 7, ParentId = 5, Priority = "Normal" }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7, TaskName = "Parent Task 3", StartDate = new DateTime(2017, 10, 28), Duration = 4, Progress = 45, ParentId = null, Priority = "High" }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8, TaskName = "Child Task 7", StartDate = new DateTime(2017, 10, 29), Duration = 3, Progress = 38, ParentId = 7, Priority = "Critical" }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9, TaskName = "Child Task 8", StartDate = new DateTime(2017, 10, 30), Duration = 7, Progress = 70, ParentId = 7, Priority = "Low" }); return BusinessObjectCollection; } } - } {% endhighlight %} diff --git a/blazor/treegrid/editing/cell-edit-types.md b/blazor/treegrid/editing/cell-edit-types.md index 6ea22ebb1f..5939282f9d 100644 --- a/blazor/treegrid/editing/cell-edit-types.md +++ b/blazor/treegrid/editing/cell-edit-types.md @@ -523,61 +523,105 @@ public class SelfReferenceData public SelfReferenceData() { } public static List GetTree() { - tree.Clear(); - int root = -1; - int TaskNameID = 0; - int ChildCount = -1; - int SubTaskCount = -1; - for (var t = 1; t <= 60; t++) + tree.Clear(); + int root = -1; + int TaskNameID = 0; + int ChildCount = -1; + int SubTaskCount = -1; + + Random gen = new Random(); + Random ran = new Random(); + + DateTime globalStart = new DateTime(2021, 01, 01); + DateTime globalEnd = new DateTime(2026, 12, 31); + + int totalRange = (globalEnd - globalStart).Days; + + + for (var t = 1; t <= 60; t++) + { + // ✅ Generate valid StartDate + DateTime startingDate = globalStart.AddDays(gen.Next(totalRange)); + + // ✅ Ensure EndDate is AFTER StartDate + int durationDays = gen.Next(5, 200); // realistic duration + DateTime endingDate = startingDate.AddDays(durationDays); + + string math = (ran.Next(3) == 0) ? "High" : (ran.Next(2) == 0) ? "Low" : "Critical"; + string progr = (ran.Next(3) == 0) ? "Started" : (ran.Next(2) == 0) ? "Open" : "In Progress"; + bool appr = (ran.Next(3) == 0); + + root++; TaskNameID++; + int rootItem = root + 1; + + tree.Add(new SelfReferenceData() { - Random gen = new Random(); - Random ran = new Random(); - DateTime start = new DateTime(2021, 06, 07); - int range = (DateTime.Today - start).Days; - DateTime startingDate = start.AddDays(gen.Next(range)); - DateTime end = new DateTime(2023, 08, 25); - int endrange = (end - DateTime.Today).Days; - DateTime endingDate = end.AddDays(gen.Next(endrange)); - string math = (ran.Next() % 3) == 0 ? "High" : (ran.Next() % 2) == 0 ? "Low" : "Critical"; - string progr = (ran.Next() % 3) == 0 ? "Started" : (ran.Next() % 2) == 0 ? "Open" : "In Progress"; - bool appr = (ran.Next() % 3) == 0 ? true : (ran.Next() % 2) == 0 ? false : true; - root++; TaskNameID++; - int rootItem = root + 1; - tree.Add(new SelfReferenceData() { TaskID = rootItem, TaskName = "Parent task " + TaskNameID.ToString(), StartDate = startingDate, EndDate = endingDate, IsParent = true, ParentID = null, Progress = progr, Priority = math, Duration = ran.Next(1, 50)}); - int parent = tree.Count; - for (var c = 0; c < 2; c++) - { - DateTime start1 = new DateTime(2021, 07, 09); - int range1 = (DateTime.Today - start1).Days; - DateTime startingDate1 = start1.AddDays(gen.Next(range1)); - DateTime end1 = new DateTime(2022, 08, 23); - int endrange1 = (end1 - DateTime.Today).Days; - DateTime endingDate1 = end1.AddDays(gen.Next(endrange1)); + TaskID = rootItem, + TaskName = "Parent task " + TaskNameID, + StartDate = startingDate, + EndDate = endingDate, + IsParent = true, + ParentID = null, + Progress = progr, + Priority = math, + Duration = durationDays + }); + + int parent = tree.Count; + + for (var c = 0; c < 2; c++) + { + // ✅ Child Start AFTER parent start + DateTime childStart = startingDate.AddDays(gen.Next(1, 30)); + + // ✅ Child End AFTER child start + DateTime childEnd = childStart.AddDays(gen.Next(5, 100)); + root++; ChildCount++; - 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"; - appr = (ran.Next() % 3) == 0 ? true : (ran.Next() % 2) == 0 ? false : true; - int iD = root + 1; - tree.Add(new SelfReferenceData() { TaskID = iD, TaskName = "Child task " + (ChildCount + 1).ToString(), StartDate = startingDate1, EndDate = endingDate1, IsParent = (((parent + c + 1) % 3) == 0), ParentID = rootItem, Progress = progr, Priority = val, Duration = ran.Next(1, 50)}); - if ((((parent + c + 1) % 3) == 0)) + int iD = root + 1; + + string val = ((parent + c + 1) % 3 == 0) ? "Low" : "Critical"; + progr = (ran.Next(3) == 0) ? "In Progress" : (ran.Next(2) == 0) ? "Open" : "Validated"; + + tree.Add(new SelfReferenceData() + { + TaskID = iD, + TaskName = "Child task " + (ChildCount + 1), + StartDate = childStart, + EndDate = childEnd, + IsParent = ((parent + c + 1) % 3 == 0), + ParentID = rootItem, + Progress = progr, + Priority = val, + Duration = (childEnd - childStart).Days + }); + + if (((parent + c + 1) % 3) == 0) + { + for (var s = 0; s < 3; s++) { - int immParent = tree.Count; - for (var s = 0; s < 3; s++) - { - DateTime start2 = new DateTime(2021, 05, 05); - int range2 = (DateTime.Today - start2).Days; - DateTime startingDate2 = start2.AddDays(gen.Next(range2)); - DateTime end2 = new DateTime(2024, 06, 16); - int endrange2 = (end2 - DateTime.Today).Days; - DateTime endingDate2 = end2.AddDays(gen.Next(endrange2)); + // ✅ SubTask inside child range + DateTime subStart = childStart.AddDays(gen.Next(1, 15)); + DateTime subEnd = subStart.AddDays(gen.Next(3, 50)); + root++; SubTaskCount++; - string Prior = (immParent % 2 == 0) ? "Validated" : "Normal"; - tree.Add(new SelfReferenceData() { TaskID = root + 1, TaskName = "Sub task " + (SubTaskCount + 1).ToString(), StartDate = startingDate2, EndDate = endingDate2, IsParent = false, ParentID = iD, Progress = (immParent % 2 == 0) ? "In Progress" : "Closed", Priority = Prior, Duration = ran.Next(1, 50)}); - } + + tree.Add(new SelfReferenceData() + { + TaskID = root + 1, + TaskName = "Sub task " + (SubTaskCount + 1), + StartDate = subStart, + EndDate = subEnd, + IsParent = false, + ParentID = iD, + Progress = (s % 2 == 0) ? "In Progress" : "Closed", + Priority = (s % 2 == 0) ? "Validated" : "Normal", + Duration = (subEnd - subStart).Days + }); } } } + } return tree; } } diff --git a/blazor/treegrid/editing/column-validation.md b/blazor/treegrid/editing/column-validation.md index ac7c4ff5f0..e870bb4123 100644 --- a/blazor/treegrid/editing/column-validation.md +++ b/blazor/treegrid/editing/column-validation.md @@ -55,6 +55,7 @@ Toolbar="@(new List() { "Add", "Edit", "Delete", "Update", "Cancel" })"> public int? Duration { get; set;} public int? Progress { get; set;} public int? ParentId { get; set;} + public bool IsParent { get; set; } } public static List GetSelfDataSource() @@ -96,9 +97,9 @@ Custom validation can be used by overriding the IsValid method inside the class The following sample code demonstrates custom validations implemented in the fields `Duration` and `Priority` . ```cshtml -@using TreeGridComponent. Data; -@using Syncfusion. Blazor. TreeGrid; -@using System. ComponentModel. DataAnnotations; +@using TreeGridComponent.Data; +@using Syncfusion.Blazor.TreeGrid; +@using System.ComponentModel.DataAnnotations; @@ -181,7 +182,7 @@ Toolbar="@(new List() { "Edit", "Update", "Cancel" })"> ```cshtml -namespace TreeGridComponent. Data +namespace TreeGridComponent.Data { public class BusinessObject @@ -221,9 +222,9 @@ In the below code example, the following things have been done. {% highlight c# %} -using Microsoft. AspNetCore. Components; -using Microsoft. AspNetCore. Components. Forms; -using Syncfusion. Blazor. Grids; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Forms; +using Syncfusion.Blazor.Grids; public class MyCustomValidator : ComponentBase { @@ -303,8 +304,8 @@ public class MyCustomValidator : ComponentBase {% highlight razor %} -@using TreeGridComponent. Data; -@using Syncfusion. Blazor. TreeGrid; +@using TreeGridComponent.Data; +@using Syncfusion.Blazor.TreeGrid; @inject WeatherForecastService ForecastService + Mode="Syncfusion.Blazor.TreeGrid.EditMode.Dialog"> @@ -472,7 +473,7 @@ Toolbar="@(new List() { "Add", "Edit", "Update", "Cancel", "Delete" })"> {% highlight c# %} -namespace TreeGridComponent. Data +namespace TreeGridComponent.Data { public class Tree diff --git a/blazor/treegrid/editing/command-column-editing.md b/blazor/treegrid/editing/command-column-editing.md index f1dcb56eeb..30be6498a2 100644 --- a/blazor/treegrid/editing/command-column-editing.md +++ b/blazor/treegrid/editing/command-column-editing.md @@ -100,7 +100,11 @@ The custom command buttons can be added in a column by using the [Commands](http The following sample code demonstrates adding custom command in the **Manage Records** column and the `CommandClicked` event which triggers when the command is clicked, -```cshtml +{% tabs %} + +{% highlight razor %} + +@using TreeGridComponent.Data; @using Syncfusion.Blazor.TreeGrid; @using Syncfusion.Blazor.Grids; @@ -121,44 +125,61 @@ The following sample code demonstrates adding custom command in the **Manage Rec @code{ - public class TreeData + public List TreeGridData { get; set; } + + protected override void OnInitialized() + { + // Use the shared data provider defined earlier in this file + this.TreeGridData = TreeData.GetSelfDataSource().ToList(); + } + + public void OnCommandClicked(CommandClickEventArgs args) + { + // Read clicked row and command column + var row = args.RowData; + var cmd = args.CommandColumn; // inspect to determine which command was clicked + var id = row?.TaskId; + + // Minimal runnable action: log the clicked row id to console + Console.WriteLine($"Details clicked for TaskId: {id}"); + } +} +{% endhighlight %} +{% highlight c# %} + +namespace TreeGridComponent.Data { + +public class TreeData { public class BusinessObject { - public int TaskId { get; set; } - public string TaskName { get; set; } - public int? Duration { get; set; } - public int? Progress { get; set; } - public int? ParentId { get; set; } + public int TaskId { get; set;} + public string TaskName { get; set;} + public int? Duration { get; set;} + public int? Progress { get; set;} + public int? ParentId { get; set;} } public static List GetSelfDataSource() { List BusinessObjectCollection = new List(); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, ParentId = null }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2, TaskName = "Child task 1", Progress = 80, ParentId = 1 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 2 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4, TaskName = "Child task 3", Duration = 6, Progress = 77, ParentId = 3 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5, TaskName = "Parent Task 2", Duration = 10, Progress = 70, ParentId = null }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 5 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7, TaskName = "Child Task 2", Duration = 5, Progress = 65, ParentId = 5 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8, TaskName = "Child task 3", Duration = 6, Progress = 77, ParentId = 5 }); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9, TaskName = "Child task 4", Duration = 6, Progress = 77, ParentId = 5 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1,TaskName = "Parent Task 1",Duration = 10,Progress = 70,ParentId = null }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2,TaskName = "Child task 1",Progress = 80,ParentId = 1 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3,TaskName = "Child Task 2",Duration = 5,Progress = 65,ParentId = 2 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4,TaskName = "Child task 3",Duration = 6,Progress = 77,ParentId = 3 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5,TaskName = "Parent Task 2",Duration = 10,Progress = 70,ParentId = null}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6,TaskName = "Child task 1",Duration = 4,Progress = 80,ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7,TaskName = "Child Task 2",Duration = 5,Progress = 65,ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8,TaskName = "Child task 3",Duration = 6,Progress = 77,ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9,TaskName = "Child task 4",Duration = 6,Progress = 77,ParentId = 5}); return BusinessObjectCollection; } } - - public List TreeGridData { get; set; } - protected override void OnInitialized() - { - this.TreeGridData = TreeData.GetSelfDataSource().ToList(); - } - public void OnCommandClicked(CommandClickEventArgs args) - { - // Perform required operations here - } } -``` + +{% endhighlight %} + +{% endtabs %} The following image represents the custom command added in the **Manage Records** column of the Tree Grid component, ![Blazor TreeGrid with Custom Command](../images/blazor-treegrid-custom-command.webp) \ No newline at end of file diff --git a/blazor/treegrid/editing/template-editing.md b/blazor/treegrid/editing/template-editing.md index be76153989..0f06bd77e0 100644 --- a/blazor/treegrid/editing/template-editing.md +++ b/blazor/treegrid/editing/template-editing.md @@ -27,6 +27,8 @@ In some cases, the new field editors must be added in the dialog which are not p @using TreeGridComponent.Data; @using Syncfusion.Blazor.TreeGrid; +@using Syncfusion.Blazor.Inputs; +@using Syncfusion.Blazor.Grids; @using Syncfusion.Blazor.DropDowns; @@ -85,7 +87,7 @@ In some cases, the new field editors must be added in the dialog which are not p this.TreeGridData = TreeData.GetSelfDataSource().ToList(); } - public void RowCreatedHandler(RowCreatedEventArgs args) + public void RowCreatedHandler(RowCreatedEventArgs args) { Check = true; } diff --git a/blazor/treegrid/filtering.md b/blazor/treegrid/filtering.md index 335a707d41..e93a936d00 100644 --- a/blazor/treegrid/filtering.md +++ b/blazor/treegrid/filtering.md @@ -56,21 +56,22 @@ namespace TreeGridComponent.Data { public string TaskName { get; set;} public int? Duration { get; set;} public int? Progress { get; set;} + public DateTime? StartDate { get; set; } public string Priority { get; set;} public int? ParentId { get; set;} public static List GetSelfDataSource() { 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",Duration = 4,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}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1,TaskName = "Parent Task 1", StartDate = new DateTime(2017, 08, 12), Duration = 10,Progress = 70,Priority = "Critical",ParentId = null }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2,TaskName = "Child task 1", StartDate = new DateTime(2017, 03, 2), Duration = 4,Progress = 80,Priority = "Low",ParentId = 1 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3,TaskName = "Child Task 2", StartDate = new DateTime(2017, 03, 6), Duration = 5,Progress = 65,Priority = "Critical",ParentId = 2 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4,TaskName = "Child task 3", StartDate = new DateTime(2017, 03, 9), Duration = 6,Priority = "High",Progress = 77,ParentId = 3 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5,TaskName = "Parent Task 2", StartDate = new DateTime(2017, 09, 12), Duration = 10,Progress = 70,Priority = "Critical",ParentId = null}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6,TaskName = "Child task 1", StartDate = new DateTime(2017, 04, 5), Duration = 4,Progress = 80,Priority = "Critical",ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7,TaskName = "Child Task 2", StartDate = new DateTime(2017, 04, 8), Duration = 5,Progress = 65,Priority = "Low",ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8,TaskName = "Child task 3", StartDate = new DateTime(2017, 04, 12), Duration = 6,Progress = 77,Priority = "High",ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9,TaskName = "Child task 4", StartDate = new DateTime(2017, 05, 12), Duration = 6,Progress = 77,Priority = "Low",ParentId = 5}); return BusinessObjectCollection; } } @@ -337,74 +338,77 @@ In the [ValueChange](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Dro namespace TreeGridComponent.Data { public class SelfReferenceData - { + { public static List tree = new List(); 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 Prioritize Priority { get; set; } + public String Priority { get; set; } public double? Duration { get; set; } public int? ParentID { get; set; } public bool? IsParent { get; set; } - public int? ParentItem { get; set;} + public bool? Approved { get; set; } + public int? ParentItem { get; set; } public SelfReferenceData() { } public static List GetTree() { - tree.Clear(); - int root = -1; - int TaskNameID = 0; - int ChildCount = -1; - int SubTaskCount = -1; - var values = Enum.GetValues(typeof(Prioritize)); - for (var t = 1; t <= 60; t++) + tree.Clear(); + int root = -1; + int TaskNameID = 0; + int ChildCount = -1; + int SubTaskCount = -1; + for (var t = 1; t <= 50; t++) + { + DateTime start = new DateTime(2022, 08, 25); + DateTime end = new DateTime(2027, 08, 25); + DateTime startingDate = start.AddDays(t + 2); + DateTime endingDate = end.AddDays(t + 20); + string math = ""; + string progr = ""; + bool appr = true; + int duration = 0; + duration = (t % 2 == 0) ? 52 : (t % 5 == 0) ? 14 : (t % 3 == 0) ? 25 : 34; + math = (t % 3) == 0 ? "High" : (t % 2) == 0 ? "Low" : "Critical"; + progr = (t % 3) == 0 ? "Started" : (t % 2) == 0 ? "Open" : "In Progress"; + appr = (t % 3) == 0 ? true : (t % 2) == 0 ? false : true; + root++; TaskNameID++; + int rootItem = root + 1; + tree.Add(new SelfReferenceData() { TaskID = rootItem, TaskName = "Parent task " + TaskNameID.ToString(), StartDate = startingDate, EndDate = endingDate, IsParent = true, ParentID = null, Progress = progr, Priority = math, Duration = duration, Approved = appr }); + int parent = tree.Count; + for (var c = 0; c < 2; c++) { - Random gen = new Random(); - Random ran = new Random(); - DateTime start = new DateTime(2021, 06, 07); - int range = (DateTime.Today - start).Days; - DateTime startingDate = start.AddDays(gen.Next(range)); - DateTime end = new DateTime(2023, 08, 25); - int endrange = (end - DateTime.Today).Days; - DateTime endingDate = end.AddDays(gen.Next(endrange)); - string progr = (ran.Next() % 3) == 0 ? "Started" : (ran.Next() % 2) == 0 ? "Open" : "In Progress"; - bool appr = (ran.Next() % 3) == 0 ? true : (ran.Next() % 2) == 0 ? false : true; - root++; TaskNameID++; - int rootItem = root + 1; - tree.Add(new SelfReferenceData() { TaskID = rootItem, TaskName = "Parent task " + TaskNameID.ToString(), StartDate = startingDate, EndDate = endingDate, IsParent = true, ParentID = null, Progress = progr, Priority = (Prioritize)(values.GetValue(gen.Next(values.Length))), Duration = ran.Next(1, 50) }); - int parent = tree.Count; - for (var c = 0; c < 2; c++) - { - DateTime start1 = new DateTime(2021, 07, 09); - int range1 = (DateTime.Today - start1).Days; - DateTime startingDate1 = start1.AddDays(gen.Next(range1)); - DateTime end1 = new DateTime(2022, 08, 23); - int endrange1 = (end1 - DateTime.Today).Days; - DateTime endingDate1 = end1.AddDays(gen.Next(endrange1)); + DateTime start1 = new DateTime(2022, 08, 25); + DateTime startingDate1 = start1.AddDays(c + 4); + DateTime end1 = new DateTime(2025, 06, 16); + DateTime endingDate1 = end1.AddDays(c + 15); root++; ChildCount++; - int parn = parent + c + 1; - progr = (ran.Next() % 3) == 0 ? "In Progress" : (ran.Next() % 2) == 0 ? "Open" : "Validated"; - appr = (ran.Next() % 3) == 0 ? true : (ran.Next() % 2) == 0 ? false : true; - int iD = root + 1; - tree.Add(new SelfReferenceData() { TaskID = iD, TaskName = "Child task " + (ChildCount + 1).ToString(), StartDate = startingDate1, EndDate = endingDate1, IsParent = (((parent + c + 1) % 3) == 0), ParentID = rootItem, Progress = progr, Priority = (Prioritize)(values.GetValue(gen.Next(values.Length))), Duration = ran.Next(1, 50) }); - if ((((parent + c + 1) % 3) == 0)) - { + int parn = parent + c + 1; + string val = ""; + duration = (c % 3 == 0) ? 1 : (c % 2 == 0) ? 12 : 98; + val = ((parent + c + 1) % 3 == 0) ? "Low" : "Critical"; + progr = ((c + 1) % 3) == 0 ? "In Progress" : ((c + 1) % 2) == 0 ? "Open" : "Validated"; + appr = ((c + 1) % 3) == 0 ? true : ((c + 3) % 2) == 0 ? false : true; + int iD = root + 1; + tree.Add(new SelfReferenceData() { TaskID = iD, TaskName = "Child task " + (ChildCount + 1).ToString(), StartDate = startingDate1, EndDate = endingDate1, IsParent = (((parent + c + 1) % 3) == 0), ParentID = rootItem, Progress = progr, Priority = val, Duration = duration, Approved = appr }); + if ((((parent + c + 1) % 3) == 0)) + { int immParent = tree.Count; - for (var s = 0; s < 3; s++) - { - DateTime start2 = new DateTime(2021, 05, 05); - int range2 = (DateTime.Today - start2).Days; - DateTime startingDate2 = start2.AddDays(gen.Next(range2)); + for (var s = 0; s < 3; s++) + { + DateTime start2 = new DateTime(2022, 08, 25); + DateTime startingDate2 = start2.AddDays(s + 4); DateTime end2 = new DateTime(2024, 06, 16); - int endrange2 = (end2 - DateTime.Today).Days; - DateTime endingDate2 = end2.AddDays(gen.Next(endrange2)); + DateTime endingDate2 = end2.AddDays(s + 13); root++; SubTaskCount++; - tree.Add(new SelfReferenceData() { TaskID = root + 1, TaskName = "Sub task " + (SubTaskCount + 1).ToString(), StartDate = startingDate2, EndDate = endingDate2, IsParent = false, ParentID = iD, Progress = (immParent % 2 == 0) ? "In Progress" : "Closed", Priority = (Prioritize)(values.GetValue(gen.Next(values.Length))), Duration = ran.Next(1, 50) }); - } + duration = (s % 2 == 0) ? 67 : 14; + string Prior = (immParent % 2 == 0) ? "Validated" : "Normal"; + tree.Add(new SelfReferenceData() { TaskID = root + 1, TaskName = "Sub task " + (SubTaskCount + 1).ToString(), StartDate = startingDate2, EndDate = endingDate2, IsParent = false, ParentID = iD, Progress = (immParent % 2 == 0) ? "In Progress" : "Closed", Priority = Prior, Duration = duration, Approved = appr }); } } } + } return tree; } } diff --git a/blazor/treegrid/filtering/excel-like-filter.md b/blazor/treegrid/filtering/excel-like-filter.md index 348fe3ae2f..74e88dabe7 100644 --- a/blazor/treegrid/filtering/excel-like-filter.md +++ b/blazor/treegrid/filtering/excel-like-filter.md @@ -60,7 +60,7 @@ namespace TreeGridComponent.Data { { 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",Duration = 4,,Progress = 80,Priority = "Low",ParentId = 1 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2,TaskName = "Child task 1",Duration = 4,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}); @@ -141,7 +141,7 @@ namespace TreeGridComponent.Data { { 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",Duration = 4,,Progress = 80,Priority = "Low",ParentId = 1 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2,TaskName = "Child task 1",Duration = 4,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}); @@ -217,12 +217,12 @@ In the following sample we have set the height and width of the TaskId and TaskN public void FilterDialogOpeningHandler(FilterDialogOpeningEventArgs args) { - if(Args.ColumnName == "TaskName") + if(args.ColumnName == "TaskName") { IsLarge = true; IsSmall = false; } - else if(Args.ColumnName == "TaskId") + else if(args.ColumnName == "TaskId") { IsSmall = true; IsLarge = false; diff --git a/blazor/treegrid/filtering/filter-bar.md b/blazor/treegrid/filtering/filter-bar.md index 5c81678320..7f8f578163 100644 --- a/blazor/treegrid/filtering/filter-bar.md +++ b/blazor/treegrid/filtering/filter-bar.md @@ -67,6 +67,7 @@ namespace TreeGridComponent.Data { public int TaskId { get; set;} public string TaskName { get; set;} public int? Duration { get; set;} + public DateTime? StartDate { get; set; } public int? Progress { get; set;} public string Priority { get; set;} public int? ParentId { get; set;} @@ -74,15 +75,15 @@ namespace TreeGridComponent.Data { public static List GetSelfDataSource() { 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",Duration = 4,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}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1,TaskName = "Parent Task 1", StartDate = new DateTime(2017, 08, 12), Duration = 10,Progress = 70,Priority = "Critical",ParentId = null }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2,TaskName = "Child task 1", StartDate = new DateTime(2017, 03, 2), Duration = 4,Progress = 80,Priority = "Low",ParentId = 1 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3,TaskName = "Child Task 2", StartDate = new DateTime(2017, 03, 6), Duration = 5,Progress = 65,Priority = "Critical",ParentId = 2 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4,TaskName = "Child task 3", StartDate = new DateTime(2017, 03, 9), Duration = 6,Priority = "High",Progress = 77,ParentId = 3 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5,TaskName = "Parent Task 2", StartDate = new DateTime(2017, 09, 12), Duration = 10,Progress = 70,Priority = "Critical",ParentId = null}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6,TaskName = "Child task 1", StartDate = new DateTime(2017, 04, 5), Duration = 4,Progress = 80,Priority = "Critical",ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7,TaskName = "Child Task 2", StartDate = new DateTime(2017, 04, 8), Duration = 5,Progress = 65,Priority = "Low",ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8,TaskName = "Child task 3", StartDate = new DateTime(2017, 04, 12), Duration = 6,Progress = 77,Priority = "High",ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9,TaskName = "Child task 4", StartDate = new DateTime(2017, 05, 12), Duration = 6,Progress = 77,Priority = "Low",ParentId = 5}); return BusinessObjectCollection; } } @@ -105,58 +106,76 @@ In the following sample, the dropdown is used as a custom component in the Durat {% highlight razor %} -@using TreeGridComponent.Data; -@using Syncfusion.Blazor.TreeGrid; -@using Syncfusion.Blazor.Data; +@using TreeGridComponent.Data +@using Syncfusion.Blazor.TreeGrid +@using Syncfusion.Blazor.Data +@using Syncfusion.Blazor.DropDowns +@using Syncfusion.Blazor.Grids + + - - - - - + + + + + - - + @{ + var predicate = context as PredicateModel; + var currentValue = predicate?.Value?.ToString(); // safe + } + + + + + + - - + + + -@code{ - - SfTreeGrid TreeGrid; +@code { + private SfTreeGrid? TreeGrid; - public List DropDownData { get; set; } = new List(); - - public List TreeGridData { get; set; } + public List DropDownData { get; set; } = new(); + public List TreeGridData { get; set; } = new(); protected override void OnInitialized() { - this.TreeGridData = BusinessObject.GetSelfDataSource().ToList(); + TreeGridData = BusinessObject.GetSelfDataSource().ToList(); - this.DropDownData.Add("10"); - this.DropDownData.Add("50"); - this.DropDownData.Add("5"); - this.DropDownData.Add("6"); - this.DropDownData.Add("4"); - this.DropDownData.Add("All"); - } + DropDownData.AddRange(new[] { "10", "50", "5", "6", "4", "All" }); + } - public void change(Syncfusion.Blazor.DropDowns.ChangeEventArgs Args) + private async Task OnDurationChange(ChangeEventArgs args) { - if (Args.Value == "All") + if (TreeGrid is null) return; + + if (args?.Value == "All" || string.IsNullOrWhiteSpace(args?.Value)) { - List Data = new List(); - Data.Add("Duration"); - TreeGrid.ClearFilteringAsync(Data); + await TreeGrid.ClearFilteringAsync(new List { "Duration" }); } else { - TreeGrid.FilterByColumnAsync("Duration", "equal", Args.Value); + await TreeGrid.FilterByColumnAsync("Duration", "equal", args.Value); } } } @@ -171,23 +190,24 @@ namespace TreeGridComponent.Data { { public int TaskId { get; set;} public string TaskName { get; set;} + public DateTime? StartDate { 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() { 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",Duration = 4,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}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1,TaskName = "Parent Task 1", StartDate = new DateTime(2017, 08, 12), Duration = 10,Progress = 70,Priority = "Critical",ParentId = null }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2,TaskName = "Child task 1", StartDate = new DateTime(2017, 03, 2), Duration = 4,Progress = 80,Priority = "Low",ParentId = 1 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3,TaskName = "Child Task 2", StartDate = new DateTime(2017, 03, 6), Duration = 5,Progress = 65,Priority = "Critical",ParentId = 2 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4,TaskName = "Child task 3", StartDate = new DateTime(2017, 03, 9), Duration = 6,Priority = "High",Progress = 77,ParentId = 3 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5,TaskName = "Parent Task 2", StartDate = new DateTime(2017, 09, 12), Duration = 10,Progress = 70,Priority = "Critical",ParentId = null}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6,TaskName = "Child task 1", StartDate = new DateTime(2017, 04, 5), Duration = 4,Progress = 80,Priority = "Critical",ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7,TaskName = "Child Task 2", StartDate = new DateTime(2017, 04, 8), Duration = 5,Progress = 65,Priority = "Low",ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8,TaskName = "Child task 3", StartDate = new DateTime(2017, 04, 12), Duration = 6,Progress = 77,Priority = "High",ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9,TaskName = "Child task 4", StartDate = new DateTime(2017, 05, 12), Duration = 6,Progress = 77,Priority = "Low",ParentId = 5}); return BusinessObjectCollection; } } @@ -247,6 +267,7 @@ namespace TreeGridComponent.Data { public int TaskId { get; set;} public string TaskName { get; set;} public int? Duration { get; set;} + public DateTime? StartDate { get; set; } public int? Progress { get; set;} public string Priority { get; set;} public int? ParentId { get; set;} @@ -254,45 +275,15 @@ namespace TreeGridComponent.Data { public static List GetSelfDataSource() { 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",Duration = 4,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}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 10,TaskName = "Parent Task 3",Duration = 10,Progress = 70,Priority = "Critical",ParentId = null}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId =11,TaskName = "Child task 1",Duration = 4,Progress = 80,Priority = "Critical",ParentId = 10}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 12,TaskName = "Child Task 2",Duration = 5,Progress = 65,Priority = "Low",ParentId = 10}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 13,TaskName = "Child task 3",Duration = 6,Progress = 77,Priority = "High",ParentId = 10}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 14,TaskName = "Child task 4",Duration = 6,Progress = 77,Priority = "Low",ParentId = 10}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 15,TaskName = "Parent Task 4",Duration = 10,Progress = 70,Priority = "Critical",ParentId = null}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 16,TaskName = "Child task 1",Duration = 4,Progress = 80,Priority = "Critical",ParentId = 15}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 17,TaskName = "Child Task 2",Duration = 5,Progress = 65,Priority = "Low",ParentId = 15}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 18,TaskName = "Child task 3",Duration = 6,Progress = 77,Priority = "High",ParentId = 15}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 19,TaskName = "Child task 4",Duration = 6,Progress = 77,Priority = "Low",ParentId = 15}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 20,TaskName = "Parent Task 5",Duration = 10,Progress = 70,Priority = "Critical",ParentId = null}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 21,TaskName = "Child task 1",Duration = 4,Progress = 80,Priority = "Critical",ParentId = 20}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 22,TaskName = "Child Task 2",Duration = 5,Progress = 65,Priority = "Low",ParentId = 20}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 23,TaskName = "Child task 3",Duration = 6,Progress = 77,Priority = "High",ParentId = 20}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 24,TaskName = "Child task 4",Duration = 6,Progress = 77,Priority = "Low",ParentId = 20}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 25,TaskName = "Parent Task 6",Duration = 10,Progress = 70,Priority = "Critical",ParentId = null}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 26,TaskName = "Child task 1",Duration = 4,Progress = 80,Priority = "Critical",ParentId = 25}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 27,TaskName = "Child Task 2",Duration = 5,Progress = 65,Priority = "Low",ParentId = 25}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 28,TaskName = "Child task 3",Duration = 6,Progress = 77,Priority = "High",ParentId = 25}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 29,TaskName = "Child task 4",Duration = 6,Progress = 77,Priority = "Low",ParentId = 25}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 30,TaskName = "Parent Task 7",Duration = 10,Progress = 70,Priority = "Critical",ParentId = null}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 31,TaskName = "Child task 1",Duration = 4,Progress = 80,Priority = "Critical",ParentId = 30}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 32,TaskName = "Child Task 2",Duration = 5,Progress = 65,Priority = "Low",ParentId = 30}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 33,TaskName = "Child task 3",Duration = 6,Progress = 77,Priority = "High",ParentId = 30}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 34,TaskName = "Child task 4",Duration = 6,Progress = 77,Priority = "Low",ParentId = 30}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 35,TaskName = "Parent Task 8",Duration = 10,Progress = 70,Priority = "Critical",ParentId = null}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 36,TaskName = "Child task 1",Duration = 4,Progress = 80,Priority = "Critical",ParentId = 35}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 37,TaskName = "Child Task 2",Duration = 5,Progress = 65,Priority = "Low",ParentId = 35}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 38,TaskName = "Child task 3",Duration = 6,Progress = 77,Priority = "High",ParentId = 35}); - BusinessObjectCollection.Add(new BusinessObject() { TaskId = 39,TaskName = "Child task 4",Duration = 6,Progress = 77,Priority = "Low",ParentId = 35}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1,TaskName = "Parent Task 1", StartDate = new DateTime(2017, 08, 12), Duration = 10,Progress = 70,Priority = "Critical",ParentId = null }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2,TaskName = "Child task 1", StartDate = new DateTime(2017, 03, 2), Duration = 4,Progress = 80,Priority = "Low",ParentId = 1 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3,TaskName = "Child Task 2", StartDate = new DateTime(2017, 03, 6), Duration = 5,Progress = 65,Priority = "Critical",ParentId = 2 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4,TaskName = "Child task 3", StartDate = new DateTime(2017, 03, 9), Duration = 6,Priority = "High",Progress = 77,ParentId = 3 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5,TaskName = "Parent Task 2", StartDate = new DateTime(2017, 09, 12), Duration = 10,Progress = 70,Priority = "Critical",ParentId = null}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6,TaskName = "Child task 1", StartDate = new DateTime(2017, 04, 5), Duration = 4,Progress = 80,Priority = "Critical",ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7,TaskName = "Child Task 2", StartDate = new DateTime(2017, 04, 8), Duration = 5,Progress = 65,Priority = "Low",ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8,TaskName = "Child task 3", StartDate = new DateTime(2017, 04, 12), Duration = 6,Progress = 77,Priority = "High",ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9,TaskName = "Child task 4", StartDate = new DateTime(2017, 05, 12), Duration = 6,Progress = 77,Priority = "Low",ParentId = 5}); return BusinessObjectCollection; } } @@ -354,6 +345,7 @@ namespace TreeGridComponent.Data { public int TaskId { get; set;} public string TaskName { get; set;} public int? Duration { get; set;} + public DateTime? StartDate { get; set; } public int? Progress { get; set;} public string Priority { get; set;} public int? ParentId { get; set;} @@ -361,15 +353,15 @@ namespace TreeGridComponent.Data { public static List GetSelfDataSource() { 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",Duration = 4,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}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1,TaskName = "Parent Task 1", StartDate = new DateTime(2017, 08, 12), Duration = 10,Progress = 70,Priority = "Critical",ParentId = null }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2,TaskName = "Child task 1", StartDate = new DateTime(2017, 03, 2), Duration = 4,Progress = 80,Priority = "Low",ParentId = 1 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3,TaskName = "Child Task 2", StartDate = new DateTime(2017, 03, 6), Duration = 5,Progress = 65,Priority = "Critical",ParentId = 2 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4,TaskName = "Child task 3", StartDate = new DateTime(2017, 03, 9), Duration = 6,Priority = "High",Progress = 77,ParentId = 3 }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5,TaskName = "Parent Task 2", StartDate = new DateTime(2017, 09, 12), Duration = 10,Progress = 70,Priority = "Critical",ParentId = null}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6,TaskName = "Child task 1", StartDate = new DateTime(2017, 04, 5), Duration = 4,Progress = 80,Priority = "Critical",ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7,TaskName = "Child Task 2", StartDate = new DateTime(2017, 04, 8), Duration = 5,Progress = 65,Priority = "Low",ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8,TaskName = "Child task 3", StartDate = new DateTime(2017, 04, 12), Duration = 6,Progress = 77,Priority = "High",ParentId = 5}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9,TaskName = "Child task 4", StartDate = new DateTime(2017, 05, 12), Duration = 6,Progress = 77,Priority = "Low",ParentId = 5}); return BusinessObjectCollection; } } diff --git a/blazor/treegrid/filtering/filter-menu.md b/blazor/treegrid/filtering/filter-menu.md index 8eaec62a78..9868586a40 100644 --- a/blazor/treegrid/filtering/filter-menu.md +++ b/blazor/treegrid/filtering/filter-menu.md @@ -92,39 +92,101 @@ In the following sample, dropdown is used as custom component in the duration co {% highlight razor %} @using TreeGridComponent.Data; -@using Syncfusion.Blazor.TreeGrid; -@using Syncfusion.Blazor.Data; +@using Syncfusion.Blazor.TreeGrid +@using Syncfusion.Blazor.Data +@using Syncfusion.Blazor.DropDowns +@using Syncfusion.Blazor.Grids + + + + - - - - - - + + + + + - - + @{ + + var predicate = context as PredicateModel; + + // PredicateModel.Value is object, might be int/int?/string. + int? current = null; + if (predicate?.Value is int i) current = i; + else if (predicate?.Value is int ni) current = ni; + else if (predicate?.Value != null && int.TryParse(predicate.Value.ToString(), out var parsed)) + current = parsed; + } + + + + + + - - + + + -@code{ +@code { + private SfTreeGrid? TreeGrid; - SfTreeGrid TreeGrid; + public List TreeGridData { get; set; } = new(); - public List TreeGridData { get; set; } + // Dropdown items: int? so we can represent "All" as null + public class DropItem + { + public string Text { get; set; } = ""; + public int? Value { get; set; } + } + + public List DropDownData { get; set; } = new(); protected override void OnInitialized() { - this.TreeGridData = BusinessObject.GetSelfDataSource().ToList(); + TreeGridData = BusinessObject.GetSelfDataSource().ToList(); + DropDownData = new List + { + new() { Text = "10", Value = 10 }, + new() { Text = "50", Value = 50 }, + new() { Text = "5", Value = 5 }, + new() { Text = "6", Value = 6 }, + new() { Text = "4", Value = 4 }, + new() { Text = "All", Value = null } // null => clear filter + }; } + private async Task OnDurationChange(ChangeEventArgs args) + { + if (TreeGrid is null) return; + + // "All" clears Duration filter + if (args?.Value is null) + { + await TreeGrid.ClearFilteringAsync(new List { "Duration" }); + return; + } + + await TreeGrid.FilterByColumnAsync("Duration", "equal", args.Value); + } } {% endhighlight %} @@ -194,24 +256,27 @@ The default filter operators for a GridColumn can be overridden by using the [Fi public List TreeGridData { get; set; } - public void FilterDialogOpeningHandler(FilterDialogOpeningEventArgs args) - { - if (Args.ColumnName == "TaskName")//Specify Field name - { - Args.FilterOperators = CustomerIDOperator; - } - } - - public class Operators + public class Operators : IFilterOperator { public string Value { get; set; } public string Text { get; set; } } - List CustomerIDOperator = new List { - new Operators() { Text= "Equal", Value= "equal" }, - new Operators() { Text= "Contains", Value= "contains" } + + private readonly List taskNameOperators = new() + { + new Operators { Text = "Equal", Value = "equal" }, + new Operators { Text = "Contains", Value = "contains" } }; + public void FilterDialogOpeningHandler(FilterDialogOpeningEventArgs args) + { + + if (args.ColumnName == "TaskName") + { + args.FilterOperators = taskNameOperators; + } + } + protected override void OnInitialized() { this.TreeGridData = BusinessObject.GetSelfDataSource().ToList(); @@ -255,9 +320,9 @@ namespace TreeGridComponent.Data { {% endtabs %} ```cshtml -@using Syncfusion.Blazor.TreeGrid; -@using Syncfusion.Blazor.Grids; -@using Syncfusion.Blazor.Data; +@using Syncfusion.Blazor.TreeGrid; +@using Syncfusion.Blazor.Grids; +@using Syncfusion.Blazor.Data; @@ -271,27 +336,29 @@ namespace TreeGridComponent.Data { -@code{ +@code { public List TreeGridData { get; set; } - public void FilterDialogOpeningHandler(FilterDialogOpeningEventArgs args) - { - if (Args.ColumnName == "TaskName")//Specify Field name - { - Args.FilterOperators = CustomerIDOperator; - } - } - - public class Operators + public class Operators : IFilterOperator { public string Value { get; set; } public string Text { get; set; } } - List CustomerIDOperator = new List { - new Operators() { Text= "Equal", Value= "equal" }, - new Operators() { Text= "Contains", Value= "contains" } + + private readonly List CustomerIDOperator = new() + { + new Operators { Text = "Equal", Value = "equal" }, + new Operators { Text = "Contains", Value = "contains" } }; + public void FilterDialogOpeningHandler(FilterDialogOpeningEventArgs args) + { + if (args.ColumnName == "TaskName")//Specify Field name + { + args.FilterOperators = CustomerIDOperator; + } + } + protected override void OnInitialized() { this.TreeGridData = BusinessObject.GetSelfDataSource().ToList(); diff --git a/blazor/treegrid/rows.md b/blazor/treegrid/rows.md index a9d850da36..db5f45508d 100644 --- a/blazor/treegrid/rows.md +++ b/blazor/treegrid/rows.md @@ -21,6 +21,7 @@ The appearance of a row can be customized by using the [RowDataBound](https://he @using TreeGridComponent.Data @using Syncfusion.Blazor.TreeGrid; +@using Syncfusion.Blazor.Grids; @@ -224,12 +225,13 @@ This is demonstrated in the below sample code where the [GetRowModel](https://he this.TreeGridData = TreeData.GetSelfDataSource().ToList(); } - public async Task TreeProps() + public Task TreeProps() { - var treeProps = await this.TreeGrid.GetRowModel(this.TreeGrid.GetCurrentViewRecords().ToList()[0]); + var treeProps = this.TreeGrid.GetRowModel(this.TreeGrid.GetCurrentViewRecords().ToList()[0]); var level = treeProps.Level; var expanded = treeProps.IsExpanded; var childRecords = treeProps.HasChildRecords; + return Task.CompletedTask; } } diff --git a/blazor/treegrid/rows/row-drag-and-drop.md b/blazor/treegrid/rows/row-drag-and-drop.md index 1786ea21b9..9e4cb89cd4 100644 --- a/blazor/treegrid/rows/row-drag-and-drop.md +++ b/blazor/treegrid/rows/row-drag-and-drop.md @@ -547,8 +547,7 @@ To drag and drop between two TreeGrids, enable [AllowRowDragAndDrop](https://hel @using TreeGridComponent.Data; @using Syncfusion.Blazor.TreeGrid;
-
-
+
@@ -569,11 +568,11 @@ To drag and drop between two TreeGrids, enable [AllowRowDragAndDrop](https://hel -
+
@code{ - public List TreeGridData { get; set; } - public List SecondGrid { get; set; } = new List(); + public List TreeGridData { get; set; } + public List SecondGrid { get; set; } = new List(); protected override void OnInitialized() { this.TreeGridData = WrapData.GetWrapData().ToList(); @@ -1061,7 +1060,6 @@ public class WrapData } } - {% endhighlight %} {% endtabs %} diff --git a/blazor/treegrid/scrolling.md b/blazor/treegrid/scrolling.md index 1d94f3cac5..cb74f36485 100644 --- a/blazor/treegrid/scrolling.md +++ b/blazor/treegrid/scrolling.md @@ -215,6 +215,7 @@ In the below demo, the TreeGrid headers remain sticky while scrolling within the @using TreeGridComponent.Data; @using Syncfusion.Blazor.TreeGrid; +@using Syncfusion.Blazor.Grids; @using Syncfusion.Blazor.Buttons
@@ -345,6 +346,7 @@ In this demo, the [FrozenColumns](https://help.syncfusion.com/cr/blazor/Syncfusi @using TreeGridComponent.Data; @using Syncfusion.Blazor.TreeGrid; +@using Syncfusion.Blazor.Grids; @@ -417,6 +419,7 @@ In this demo, the columns with the field name **TaskName** and **Duration** is f @using TreeGridComponent.Data; @using Syncfusion.Blazor.TreeGrid; +@using Syncfusion.Blazor.Grids; @@ -527,6 +530,88 @@ The [TreeGridColumns](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Tr {% endhighlight %} +{% highlight c# %} + +namespace TreeGridComponent.Data { + public class SelfReferenceData + { + public static List tree = new List(); + 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; } + public SelfReferenceData() { } + public static List GetTree() + { + tree.Clear(); + int root = -1; + int TaskNameID = 0; + int ChildCount = -1; + int SubTaskCount = -1; + for (var t = 1; t <= 50; t++) + { + DateTime start = new DateTime(2022, 08, 25); + DateTime end = new DateTime(2027, 08, 25); + DateTime startingDate = start.AddDays(t + 2); + DateTime endingDate = end.AddDays(t + 20); + string math = ""; + string progr = ""; + bool appr = true; + int duration = 0; + duration = (t % 2 == 0) ? 52 : (t % 5 == 0) ? 14 : (t % 3 == 0) ? 25 : 34; + math = (t % 3) == 0 ? "High" : (t % 2) == 0 ? "Low" : "Critical"; + progr = (t % 3) == 0 ? "Started" : (t % 2) == 0 ? "Open" : "In Progress"; + appr = (t % 3) == 0 ? true : (t % 2) == 0 ? false : true; + root++; TaskNameID++; + int rootItem = root + 1; + tree.Add(new SelfReferenceData() { TaskID = rootItem, TaskName = "Parent task " + TaskNameID.ToString(), StartDate = startingDate, EndDate = endingDate, IsParent = true, ParentID = null, Progress = progr, Priority = math, Duration = duration, Approved = appr }); + int parent = tree.Count; + for (var c = 0; c < 2; c++) + { + DateTime start1 = new DateTime(2022, 08, 25); + DateTime startingDate1 = start1.AddDays(c + 4); + DateTime end1 = new DateTime(2025, 06, 16); + DateTime endingDate1 = end1.AddDays(c + 15); + root++; ChildCount++; + int parn = parent + c + 1; + string val = ""; + duration = (c % 3 == 0) ? 1 : (c % 2 == 0) ? 12 : 98; + val = ((parent + c + 1) % 3 == 0) ? "Low" : "Critical"; + progr = ((c + 1) % 3) == 0 ? "In Progress" : ((c + 1) % 2) == 0 ? "Open" : "Validated"; + appr = ((c + 1) % 3) == 0 ? true : ((c + 3) % 2) == 0 ? false : true; + int iD = root + 1; + tree.Add(new SelfReferenceData() { TaskID = iD, TaskName = "Child task " + (ChildCount + 1).ToString(), StartDate = startingDate1, EndDate = endingDate1, IsParent = (((parent + c + 1) % 3) == 0), ParentID = rootItem, Progress = progr, Priority = val, Duration = duration, Approved = appr }); + if ((((parent + c + 1) % 3) == 0)) + { + int immParent = tree.Count; + for (var s = 0; s < 3; s++) + { + DateTime start2 = new DateTime(2022, 08, 25); + DateTime startingDate2 = start2.AddDays(s + 4); + DateTime end2 = new DateTime(2024, 06, 16); + DateTime endingDate2 = end2.AddDays(s + 13); + root++; SubTaskCount++; + duration = (s % 2 == 0) ? 67 : 14; + string Prior = (immParent % 2 == 0) ? "Validated" : "Normal"; + tree.Add(new SelfReferenceData() { TaskID = root + 1, TaskName = "Sub task " + (SubTaskCount + 1).ToString(), StartDate = startingDate2, EndDate = endingDate2, IsParent = false, ParentID = iD, Progress = (immParent % 2 == 0) ? "In Progress" : "Closed", Priority = Prior, Duration = duration, Approved = appr }); + } + } + } + } + return tree; + } + } +} + +{% endhighlight %} + {% endtabs %} N> If frozen columns are not specified, the frozen column separator will be displayed at the left and right ends. You can dynamically change the frozen columns by dragging the column separator. @@ -537,7 +622,9 @@ N> If frozen columns are not specified, the frozen column separator will be disp This section shows you how to invoke a [ScrollIntoViewAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.TreeGrid.SfTreeGrid-1.html#Syncfusion_Blazor_TreeGrid_SfTreeGrid_1_ScrollIntoViewAsync) method to scroll the tree grid content into view externally by passing column index or row index as parameter. In the below demo, modifying the RowIndex value triggers a vertical scroll, while changing the ColumnIndex value initiates a horizontal scroll when the corresponding button is clicked. + ```cshtml + @using Syncfusion.Blazor.Grids @using Syncfusion.Blazor.TreeGrid @using Syncfusion.Blazor.Buttons diff --git a/blazor/treegrid/selection.md b/blazor/treegrid/selection.md index 70b3a0feb7..8dcaa5ad3b 100644 --- a/blazor/treegrid/selection.md +++ b/blazor/treegrid/selection.md @@ -398,6 +398,7 @@ The Toggle selection allows to perform selection and unselection of the particul @using TreeGridComponent.Data; @using Syncfusion.Blazor.TreeGrid; +@using Syncfusion.Blazor.Grids; @@ -648,7 +649,7 @@ Retrieve selected row indexes using the `GetSelectedRowIndexesAsync` method. this.TreeGridData = TreeData.GetSelfDataSource().ToList(); } - private async void RowSelectHandler(RowSelectEventArgs Args) + private async Task RowSelectHandler(RowSelectEventArgs Args) { this.SelectedRowIndexes = await this.TreeGrid.GetSelectedRowIndexesAsync(); /// get the selected row indexes diff --git a/blazor/treegrid/sorting.md b/blazor/treegrid/sorting.md index b9568a6972..e9fbb660e4 100644 --- a/blazor/treegrid/sorting.md +++ b/blazor/treegrid/sorting.md @@ -168,19 +168,19 @@ During the sort action, the tree grid component triggers two events. The [Action @using TreeGridComponent.Data; @using Syncfusion.Blazor.TreeGrid; -@inject IJSRuntime JsRuntime; +@using Syncfusion.Blazor.Grids; +@inject IJSRuntime JsRuntime; - - - - + + + + - - - + + + - @code { public List TreeGridData { get; set; } @@ -192,12 +192,18 @@ During the sort action, the tree grid component triggers two events. The [Action private void SortingHandler(SortingEventArgs args) { - JsRuntime.InvokeAsync("window.alert", args.RequestType.ToString()); + // Example: prevent sorting on the TaskId column + if (string.Equals(args?.ColumnName, "TaskId", StringComparison.OrdinalIgnoreCase)) + { + args.Cancel = true; + + return; + } } private void SortedHandler(SortedEventArgs args) { - JsRuntime.InvokeAsync("window.alert", args.RequestType.ToString()); + // perform actions that needs to be done after sorting action } } @@ -300,8 +306,11 @@ In this TreeGrid example, custom sorting enhances project management by allowing { var a = x as TaskData; var b = y as TaskData; - bool aHasValue = int.TryParse(a?.StoryPoints ?? "", out int valA); - bool bHasValue = int.TryParse(b?.StoryPoints ?? "", out int valB); + if (a is null && b is null) return 0; + if (a is null) return -1; + if (b is null) return 1; + bool aHasValue = int.TryParse(a.StoryPoints ?? "", out int valA); + bool bHasValue = int.TryParse(b.StoryPoints ?? "", out int valB); if (!aHasValue && !bHasValue) return 0; if (!aHasValue) return -1; // Empty comes first if (!bHasValue) return 1; @@ -321,29 +330,16 @@ In this TreeGrid example, custom sorting enhances project management by allowing { var a = x as TaskData; var b = y as TaskData; - int pa = Order.GetValueOrDefault(a?.Priority ?? "", 0); - int pb = Order.GetValueOrDefault(b?.Priority ?? "", 0); + if (a is null && b is null) return 0; + if (a is null) return -1; + if (b is null) return 1; + int pa = Order.GetValueOrDefault(a.Priority ?? "", 0); + int pb = Order.GetValueOrDefault(b.Priority ?? "", 0); // Ascending order: Low → Normal → High → Critical return pa.CompareTo(pb); } } - public void ToolBarClick(Syncfusion.Blazor.Navigations.ClickEventArgs Args) - { - if (Args.Item.Id == "small") - { - RowHeightValue = 20; - } - if (Args.Item.Id == "medium") - { - RowHeightValue = 40; - } - if (Args.Item.Id == "big") - { - RowHeightValue = 60; - } - } - public class CustomComparer : IComparer { private static readonly Dictionary PriorityOrder = new() @@ -353,29 +349,21 @@ In this TreeGrid example, custom sorting enhances project management by allowing { "High", 3 }, { "Critical", 4 } }; - - public int Compare(object XRowDataToCompare, object YRowDataToCompare) + public int Compare(object? XRowDataToCompare, object? YRowDataToCompare) { var xx = XRowDataToCompare as WrapData; var yy = YRowDataToCompare as WrapData; - string stringX = xx?.Priority.ToString() ?? string.Empty; - string stringY = yy?.Priority.ToString() ?? string.Empty; + if (xx is null && yy is null) return 0; + if (xx is null) return -1; + if (yy is null) return 1; + string stringX = xx.Priority ?? string.Empty; + string stringY = yy.Priority ?? string.Empty; int priorityX = PriorityOrder.GetValueOrDefault(stringX, 1); int priorityY = PriorityOrder.GetValueOrDefault(stringY, 1); - if (priorityX == priorityY) - { - return 0; - } - else if (priorityX > priorityY) - { - return 1; - } - else - { - return -1; - } + if (priorityX == priorityY) return 0; + return priorityX > priorityY ? 1 : -1; } } } diff --git a/blazor/treegrid/state-management.md b/blazor/treegrid/state-management.md index 63e6a50115..c7ea4e26d5 100644 --- a/blazor/treegrid/state-management.md +++ b/blazor/treegrid/state-management.md @@ -105,7 +105,7 @@ You can handle the tree grid's state manually by using built-in state persistenc { await TreeGrid.SetPersistDataAsync(SavedPersistence); } - private async void ClearPersistence() + private async Task ClearPersistence() { await TreeGrid.ResetPersistDataAsync(); } @@ -133,4 +133,5 @@ You can handle the tree grid's state manually by using built-in state persistenc TreeData.Add(new BusinessObject() { TaskId = 8, TaskName = "Child Task 7", Duration = 3, Progress = 38, ParentId = 7, Priority = "Critical" }); TreeData.Add(new BusinessObject() { TaskId = 9, TaskName = "Child Task 8", Duration = 7, Progress = 70, ParentId = 7, Priority = "Low" }); } +} ``` diff --git a/blazor/treegrid/toolbar.md b/blazor/treegrid/toolbar.md index f889f599aa..e14af1bd58 100644 --- a/blazor/treegrid/toolbar.md +++ b/blazor/treegrid/toolbar.md @@ -106,8 +106,10 @@ N> The [Toolbar](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor~Syncfus Toolbar items can be enabled or disabled using the [EnableToolbarItemsAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.TreeGrid.SfTreeGrid-1.html#Syncfusion_Blazor_TreeGrid_SfTreeGrid_1_EnableToolbarItemsAsync_System_Collections_Generic_List_System_String__System_Boolean_) method. -```cshtml +{% tabs %} +{% highlight razor %} +@using TreeGridComponent.Data; @using Syncfusion.Blazor.Buttons @using Syncfusion.Blazor.TreeGrid; @using Syncfusion.Blazor.Grids; @@ -122,11 +124,10 @@ Toolbar items can be enabled or disabled using the [EnableToolbarItemsAsync](htt @{ - var Tool = (new string[] { "ExpandAll", "CollapseAll" }); + var Tool = (new string[] { "Add","Edit","Delete","Update","Cancel" }); } - @@ -136,32 +137,33 @@ Toolbar items can be enabled or disabled using the [EnableToolbarItemsAsync](htt -@code{ +@code { SfTreeGrid TreeGrid; - public void Enable() + public async void Enable() { - this.TreeGrid.EnableToolbarItemsAsync(new List() { "TreeGrid_gridcontrol_ExpandAll", "TreeGrid_gridcontrol_CollapseAll" }, true); + await this.TreeGrid.EnableToolbarItemsAsync(new List() { "Add", "Edit", "Delete", "Update", "Cancel" }, true); + await this.TreeGrid.CallStateHasChangedAsync(); } - public void Disable() + public async void Disable() { - this.TreeGrid.EnableToolbarItemsAsync(new List() { "TreeGrid_gridcontrol_ExpandAll", "TreeGrid_gridcontrol_CollapseAll" }, false); + await this.TreeGrid.EnableToolbarItemsAsync(new List() { "Add", "Edit", "Delete", "Update", "Cancel" }, false); + await this.TreeGrid.CallStateHasChangedAsync(); } - public void ToolBarClick(Syncfusion.Blazor.Navigations.ClickEventArgs Args) + public List TreeGridData { get; set; } + + protected override void OnInitialized() { - if (Args.Item.Text == "ExpandAll") - { - this.TreeGrid.ExpandAll(); - } - if (Args.Item.Text == "CollapseAll") - { - this.TreeGrid.CollapseAllAsync(); - } + this.TreeGridData = TreeData.GetSelfDataSource().ToList(); } +} +{% endhighlight %} + +{% highlight c# %} +namespace TreeGridComponent.Data { - public List TreeGridData { get; set; } public class TreeData { public int TaskId { get; set; } @@ -173,25 +175,24 @@ Toolbar items can be enabled or disabled using the [EnableToolbarItemsAsync](htt public static List GetSelfDataSource() { List TreeDataCollection = new List(); - TreeDataCollection.Add(new TreeData(){ TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, Priority = "Critical", ParentId = null }); - TreeDataCollection.Add(new TreeData(){ TaskId = 2, TaskName = "Child task 1", Progress = 80, Priority = "Low", Duration = 50, ParentId = 1 }); - TreeDataCollection.Add(new TreeData(){ TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, Priority = "Critical", ParentId = 2 }); - TreeDataCollection.Add(new TreeData(){ TaskId = 4, TaskName = "Child task 3", Duration = 6, Priority = "High", Progress = 77, ParentId = 3 }); - TreeDataCollection.Add(new TreeData(){ TaskId = 5, TaskName = "Parent Task 2", Duration = 10, Progress = 70, Priority = "Critical", ParentId = null }); - TreeDataCollection.Add(new TreeData(){ TaskId = 6, TaskName = "Child task 1", Duration = 4, Progress = 80, Priority = "Critical", ParentId = 5 }); - TreeDataCollection.Add(new TreeData(){ TaskId = 7, TaskName = "Child Task 2", Duration = 5, Progress = 65, Priority = "Low", ParentId = 5 }); - TreeDataCollection.Add(new TreeData(){ TaskId = 8, TaskName = "Child task 3", Duration = 6, Progress = 77, Priority = "High", ParentId = 5 }); - TreeDataCollection.Add(new TreeData(){ TaskId = 9, TaskName = "Child task 4", Duration = 6, Progress = 77, Priority = "Low", ParentId = 5 }); + TreeDataCollection.Add(new TreeData() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, Priority = "Critical", ParentId = null }); + TreeDataCollection.Add(new TreeData() { TaskId = 2, TaskName = "Child task 1", Progress = 80, Priority = "Low", Duration = 50, ParentId = 1 }); + TreeDataCollection.Add(new TreeData() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, Priority = "Critical", ParentId = 2 }); + TreeDataCollection.Add(new TreeData() { TaskId = 4, TaskName = "Child task 3", Duration = 6, Priority = "High", Progress = 77, ParentId = 3 }); + TreeDataCollection.Add(new TreeData() { TaskId = 5, TaskName = "Parent Task 2", Duration = 10, Progress = 70, Priority = "Critical", ParentId = null }); + TreeDataCollection.Add(new TreeData() { TaskId = 6, TaskName = "Child task 1", Duration = 4, Progress = 80, Priority = "Critical", ParentId = 5 }); + TreeDataCollection.Add(new TreeData() { TaskId = 7, TaskName = "Child Task 2", Duration = 5, Progress = 65, Priority = "Low", ParentId = 5 }); + TreeDataCollection.Add(new TreeData() { TaskId = 8, TaskName = "Child task 3", Duration = 6, Progress = 77, Priority = "High", ParentId = 5 }); + TreeDataCollection.Add(new TreeData() { TaskId = 9, TaskName = "Child task 4", Duration = 6, Progress = 77, Priority = "Low", ParentId = 5 }); return TreeDataCollection; } } - protected override void OnInitialized() - { - this.TreeGridData = TreeData.GetSelfDataSource().ToList(); - } } -``` +{% endhighlight %} + +{% endtabs %} + The following screenshots represent a TreeGrid with Enable/disable toolbar items, ![Enabling or Disabling Toolbar Items in Blazor TreeGrid](images/blazor-treegrid-enable-disable-toolbar-items.webp)