forked from syncfusion/blazor-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRemoteData.razor
52 lines (47 loc) · 3.1 KB
/
RemoteData.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@page "/treeview/remote-data"
@using Syncfusion.Blazor.Navigations
@using Syncfusion.Blazor.Data
@inherits SampleBaseComponent;
<SampleDescription>
<p>The <a href='https://www.syncfusion.com/blazor-components/blazor-treeview' target='_blank'>Blazor TreeView</a> sample demonstrates the binding data to the TreeView from remote data source. On expanding the parent node, the spinner icon will be displayed until the child nodes are loaded into the parent node. Click on node to select it, and click on icon or double click on node to expand/collapse it.</p>
</SampleDescription>
<ActionDescription>
<p><p>The TreeView component loads the data through the dataSource property, where the data can be either local data or remote data. In case of remote data, the data can be loaded from any remote services though the DataManager.</p>
<p>The DataManager will act as an interface between the service endpoint and the TreeView, that requires the below minimal information to interact with the service endpoint.</p>
<p>DataManager->url - Defines the service endpoint to fetch data. DataManager->adaptor - Defines the adaptor option. By default, ODataV4Adaptor is used for remote binding.</p>
<p>In this demo, the TreeView is bound with the dataSource from the Northwind remote service by using the DataManager instance.</p>
<p>More information about Treeview can be found in this <a href='https://blazor.syncfusion.com/documentation/treeview/data-binding/#remote-data' target='_blank'>documentation</a> section .</p></p>
</ActionDescription>
<div class="col-lg-12 control-section">
<div class="control_wrapper">
<SfTreeView TValue="TreeData">
<TreeViewFieldsSettings TValue="TreeData" Query="@employeeQuery" Id="EmployeeID" Text="FirstName" HasChildren="EmployeeID">
<SfDataManager Url="https://services.odata.org/V4/Northwind/Northwind.svc" Adaptor="Syncfusion.Blazor.Adaptors.ODataV4Adaptor" CrossDomain="true"></SfDataManager>
<TreeViewFieldChild TValue="TreeData" Query="@orderQuery" Id="OrderID" Text="ShipName" ParentID="EmployeeID">
<SfDataManager Url="https://services.odata.org/V4/Northwind/Northwind.svc" Adaptor="Syncfusion.Blazor.Adaptors.ODataV4Adaptor" CrossDomain="true"></SfDataManager>
</TreeViewFieldChild>
</TreeViewFieldsSettings>
</SfTreeView>
</div>
</div>
@code{
public static List<string> EmployeeDetails = new List<string>() { "EmployeeID", "FirstName", "Title" };
Query employeeQuery = new Query().From("Employees").Select(EmployeeDetails).Take(5);
public static List<string> OrderDetails = new List<string>() { "OrderID", "EmployeeID", "ShipName" };
Query orderQuery = new Query().From("Orders").Select(OrderDetails).Take(5);
class TreeData
{
public int? EmployeeID { get; set; }
public int OrderID { get; set; }
public string ShipName { get; set; }
public string FirstName { get; set; }
}
}
<style>
.control_wrapper {
max-width: 500px;
margin: auto;
border: 1px solid #dddddd;
border-radius: 3px;
}
</style>