Hi, currently I'm having problems with the TreeGrid trying to mark checkboxes using SelectCheckboxes or SelectRows, the checkboxes have a hierarchy, I need the checkboxes to be marked based on a condition, I attached a project with the code that I'm using, anyways I'm also adding the code here
@page "/"
@using Syncfusion.Blazor.TreeGrid;
<SfTreeGrid @ref="@TreeGrid" DataSource="@BusinessObjectCollection" IdMapping="TaskId" AllowSelection="true" ParentIdMapping="ParentId" TreeColumnIndex="0" AutoCheckHierarchy>
<TreeGridColumns>
<TreeGridColumn ShowCheckbox Width="80">TreeGridColumn>
<TreeGridColumn Field="TaskId" HeaderText="Task ID" Width="80" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right">TreeGridColumn>
<TreeGridColumn Field="TaskName" HeaderText="Task Name" Width="160">TreeGridColumn>
<TreeGridColumn Field="Duration" HeaderText="Duration" Width="100" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right">TreeGridColumn>
<TreeGridColumn Field="Progress" HeaderText="Progress" Width="100" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right">TreeGridColumn>
<TreeGridColumn Field="Priority" HeaderText="Priority" Width="80">TreeGridColumn>
TreeGridColumns>
SfTreeGrid>
<button @onclick="@(async () => await SelectCheckBoxes())">Select SelectCheckBoxesbutton>
<button @onclick="@(async () => await SelectRows())">Select SelectRowsbutton>
@code{
private SfTreeGrid<TreeData> TreeGrid;
private List<double> SelectIndex { get; set; }
List<TreeData> BusinessObjectCollection = new List<TreeData>();
protected override void OnInitialized()
{
BusinessObjectCollection.Add(new TreeData() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, Priority = "Critical", ParentId = null });
BusinessObjectCollection.Add(new TreeData() { TaskId = 2, TaskName = "Child task 1", Duration = 6, Progress = 80, Priority = "Low", ParentId = 1 });
BusinessObjectCollection.Add(new TreeData() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, Priority = "Critical", ParentId = 2 });
BusinessObjectCollection.Add(new TreeData() { TaskId = 4, TaskName = "Child task 3", Duration = 6, Priority = "High", Progress = 77, ParentId = 3 });
BusinessObjectCollection.Add(new TreeData() { TaskId = 5, TaskName = "Parent Task 2", Duration = 10, Progress = 70, Priority = "Critical", ParentId = null });
BusinessObjectCollection.Add(new TreeData() { TaskId = 6, TaskName = "Child task 1", Duration = 4, Progress = 80, Priority = "Critical", ParentId = 5 });
BusinessObjectCollection.Add(new TreeData() { TaskId = 7, TaskName = "Child Task 2", Duration = 5, Progress = 65, Priority = "Low", ParentId = 5 });
BusinessObjectCollection.Add(new TreeData() { TaskId = 8, TaskName = "Child task 3", Duration = 6, Progress = 77, Priority = "High", ParentId = 5 });
BusinessObjectCollection.Add(new TreeData() { TaskId = 9, TaskName = "Child task 4", Duration = 6, Progress = 77, Priority = "Low", ParentId = 5 });
}
public async Task SelectCheckBoxes()
{
var Source = TreeGrid.DataSource;
var IndexNum = 0;
SelectIndex = new List<double>();
foreach (var record in Source)
{
if (record.Progress > 70)
{
SelectIndex.Add(IndexNum);
}
IndexNum++;
}
await TreeGrid.SelectCheckboxes(SelectIndex.ToArray());
}
public async Task SelectRows()
{
var Source = TreeGrid.DataSource;
var IndexNum = 0;
SelectIndex = new List<double>();
foreach (var record in Source)
{
if (record.Progress > 70)
{
SelectIndex.Add(IndexNum);
}
IndexNum++;
}
await TreeGrid.SelectRows(SelectIndex.ToArray());
}
public class TreeData
{
public int TaskId { get; set; }
public string TaskName { get; set; }
public int? Duration { get; set; }
public int? Progress { get; set; }
public string Priority { get; set; }
public int? ParentId { get; set; }
}
}