Hi kavit,
Greetings from Syncfusion.
Query #: Is it possible to paging on all visible rows, not just root nodes?
By default, Blazor Tree Grid work with PageSizeMode as Root. So only the count of root node is shown in the pagination. We suggest you to set the PageSizeMode as All which is default mode which will return records based on PageSize.
<SfTreeGrid ID="Grid" DataSource="@DragData" IdMapping="TaskId" ParentIdMapping="ParentId" AllowPaging="true" TreeColumnIndex="1"> . . . . <TreeGridPageSettings PageSize="40" PageSizeMode="PageSizeMode.All"></TreeGridPageSettings> . . . . </SfTreeGrid> |
Please check the below help documentations,
https://blazor.syncfusion.com/documentation/treegrid/paging/#page-size-mode
If we misunderstood your query, kindly provide us more details regarding data binding (Remote data/Local data) for better understanding.
Kindly get back t us for further assistance.
Regards,
Shek
Not working if using customManager
@using Syncfusion.Blazor.TreeGrid
@using Syncfusion.Blazor.Grids
@using System.ComponentModel.DataAnnotations;
@using Syncfusion.Blazor.Popups
@using Syncfusion.Blazor.Buttons
<div class="col-lg-12 control-section">
<div class="content-wrapper">
<div class="row">
<SfTreeGrid @ref=sfTree TValue="SelfReferenceData" AllowFiltering="true" HasChildMapping="IsParent" IdMapping="TaskID" ParentIdMapping="ParentID"
TreeColumnIndex="1" AllowPaging="true" AllowSorting="true">
<SfDataManager AdaptorInstance="typeof(customDm)" Adaptor="Adaptors.CustomAdaptor" />
<TreeGridPageSettings PageSize="3" PageSizeMode="PageSizeMode.All">
</TreeGridPageSettings>
<TreeGridFilterSettings Type="Syncfusion.Blazor.TreeGrid.FilterType.FilterBar"></TreeGridFilterSettings>
<TreeGridColumns>
<TreeGridColumn Field="TaskID" HeaderText="Task ID" IsPrimaryKey="true" Width="80" TextAlign="TextAlign.Right"></TreeGridColumn>
<TreeGridColumn Field="TaskName" HeaderText="Task Name" Width="145"></TreeGridColumn>
<TreeGridColumn Field="StartDate" HeaderText="Start Date" Format="d" Type=ColumnType.Date Width="88" TextAlign="TextAlign.Right"></TreeGridColumn>
<TreeGridColumn Field="Duration" HeaderText="Duration" Width="100" TextAlign="TextAlign.Right"></TreeGridColumn>
<TreeGridColumn Field="Progress" HeaderText="Progress" Width="100"></TreeGridColumn>
<TreeGridColumn Field="Priority" HeaderText="Priority" Width="100"></TreeGridColumn>
</TreeGridColumns>
</SfTreeGrid>
</div>
</div>
<SfButton OnClick="clic" Content="Expand"></SfButton>
</div>
@code {
public int Count { get; set; } = 0;
private List<SelfReferenceData> TreeGridData { get; set; }
private List<string> PageSizes { get; set; }
private SfTreeGrid<SelfReferenceData> sfTree { get; set; }
protected override void OnInitialized()
{
this.PageSizes = new List<string>() { "2", "4", "5", "10", "15", "20", "All" };
}
private async Task clic()
{
var firstObj = sfTree.GetCurrentViewRecords().First();
await sfTree.ExpandByKeyAsync(firstObj.TaskID);
//await sfTree.ExpandAtLevelAsync(1);
}
public class customDm : DataAdaptor
{
public override object Read(DataManagerRequest dm, string key = null)
{
IEnumerable<SelfReferenceData> DataSource = SelfReferenceData.GetTree();
if (dm.Search != null && dm.Search.Count > 0)
{
// Searching
DataSource = DataOperations.PerformSearching(DataSource, dm.Search);
}
if (dm.Sorted != null && dm.Sorted.Count > 0)
{
// Sorting
DataSource = DataOperations.PerformSorting(DataSource, dm.Sorted);
}
if (dm.Where != null && dm.Where.Count > 0)
{
// Filtering
DataSource = DataOperations.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
}
int count = DataSource.Cast<SelfReferenceData>().Count();
if (dm.Skip != 0)
{
//Paging
DataSource = DataOperations.PerformSkip(DataSource, dm.Skip);
}
if (dm.Take != 0)
{
DataSource = DataOperations.PerformTake(DataSource, dm.Take);
}
return dm.RequiresCounts ? new DataResult() { Result = DataSource, Count = count } : (object)DataSource;
}
}
public class SelfReferenceData
{
public static List<SelfReferenceData> tree = new List<SelfReferenceData>();
[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 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<SelfReferenceData> GetTree()
{
tree.Clear();
int root = -1;
int TaskNameID = 0;
int ChildCount = -1;
int SubTaskCount = -1;
for (var t = 1; t <= 60; t++)
{
Random ran = new Random();
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 = (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), 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++;
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), 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++;
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), Approved = appr });
}
}
}
}
return tree;
}
}
}
Hi Kavit,
Currently we don’t have support for “PageSize mode All for Remote DataBinding in our TreeGrid”. Also, we have added this requirement in our feature list. You can track the current status of your request, review the resolution timeline and contact us for any further inquiries through this link.
Feedback link : https://www.syncfusion.com/feedback/30577/need-to-provide-support-for-rendering-parent-and-child-records-based-on-pagesize
We will implement this and include it in any of our upcoming releases. Please cast your vote on this feature based on the customer demand we will prioritize the features in our upcoming road map.
Regards,
Shek Mohammed Asiq