Skip to content

Commit 5a07ffe

Browse files
authored
Merge pull request #1 from SyncfusionExamples/ES-975464
ES-975464 - Resolve the ReadMe file length issue in this sample repository
2 parents f4a9d88 + f29bc22 commit 5a07ffe

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
1-
# How to populate child nodes asynchronously in uwp treegrid?
1+
# How to Populate Child Nodes Asynchronously in UWP TreeGrid?
22

3-
## About the example
3+
This example illustrates how to populate child nodes asynchronously in [UWP TreeGrid](https://www.syncfusion.com/uwp-ui-controls/treegrid) (SfTreeGrid).
44

5-
This example illustrates how to populate child nodes asynchronously in uwp treegrid
5+
You can populate the child nodes asynchronously using **async** and **await** at runtime when retrieving data from web services or any database. This can be performed by [PopulateChildNodes](https://help.syncfusion.com/cr/uwp/Syncfusion.UI.Xaml.TreeGrid.TreeNode.html#Syncfusion_UI_Xaml_TreeGrid_TreeNode_PopulateChildNodes_System_Collections_Generic_IEnumerable_System_Object__) method from [TreeGridRequestTreeItemsEventArgs.ParentNode](https://help.syncfusion.com/cr/uwp/Syncfusion.UI.Xaml.TreeGrid.TreeGridRequestTreeItemsEventArgs.html#Syncfusion_UI_Xaml_TreeGrid_TreeGridRequestTreeItemsEventArgs_ParentNode) property.
6+
7+
``` c#
8+
private async void TreeGrid_RequestTreeItems(object sender, TreeGridRequestTreeItemsEventArgs args)
9+
{
10+
if (args.ParentItem == null)
11+
{
12+
args.ChildItems = viewModel.Employees.Where(x => x.ReportsTo == -1);
13+
}
14+
//if ParentItem not null, then set args.ChildList to the child items for the given ParentItem.
15+
else
16+
{
17+
EmployeeInfo ems = args.ParentItem as EmployeeInfo;
18+
19+
if (ems != null)
20+
{
21+
await Task.Run(async () =>
22+
{
23+
await this.treeGrid.Dispatcher.RunAsync(CoreDispatcherPriority.High, async() =>
24+
{
25+
//Get the child items with time delay
26+
var childItems = await viewModel.GetEmployees(ems.ID);
27+
28+
//Populate the child nodes based on the child items
29+
args.ParentNode.PopulateChildNodes(childItems);
30+
});
31+
32+
});
33+
}
34+
}
35+
}
36+
```

0 commit comments

Comments
 (0)