Skip to content

Commit f4e2dc9

Browse files
994112: Updated the UG content and samples for Blazor DataManger Component
1 parent 5ccebab commit f4e2dc9

File tree

1 file changed

+42
-20
lines changed

1 file changed

+42
-20
lines changed

blazor/data/data-binding.md

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,53 @@ documentation: ug
1111

1212
# Data Binding in Blazor DataManager Component
1313

14-
The [SfDataManager](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Data.SfDataManager.html) acts as a gateway for both local and remote data source which uses the query to interact with the data source. It supports both local object binding and RESTful JSON data services binding.
14+
Data binding establishes a connection between a Blazor component and its data source. The Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor [DataManager](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Data.SfDataManager.html) component provides an efficient way to manage this connection. It acts as an intermediary between the data source and UI components such as [SfGrid](https://blazor.syncfusion.com/documentation/datagrid/getting-started-with-web-app).
15+
16+
The [SfDataManager](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Data.SfDataManager.html) supports two primary approaches for data binding:
17+
18+
* **Local Data Binding** – Binds in-memory collections directly to the component using the [Json](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.DataManager.html#Syncfusion_Blazor_DataManager_Json) property.
19+
20+
* **Remote Data Binding** – Connects to remote services by specifying a service endpoint [URL](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.DataManager.html#Syncfusion_Blazor_DataManager_Url) and configuring the [Adaptor](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.DataManager.html#Syncfusion_Blazor_DataManager_Adaptor) property.
21+
22+
Built-in adaptors enable seamless integration with services such as **OData** and **Web API**. Common operations like **filtering**, **sorting**, **paging**, and **grouping** can be executed on the **client** or **server** based on the selected adaptor.
1523

1624
## Local data binding
1725

18-
Local data can be bound to the DataGrid component by assigning the array of objects to the [Json](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.DataManager.html#Syncfusion_Blazor_DataManager_Json) property of [SfDataManager](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Data.SfDataManager.html).
26+
Local data binding connects a component to data that resides in the application’s memory. This approach is suitable when the dataset is already available and does not require frequent updates from an external source.
27+
28+
**Key Benefits**
29+
30+
* Eliminates **network latency**.
31+
* Ideal for **small to medium** sized collections.
32+
* Simplifies configuration since no remote service is involved.
33+
* Operations such as **sorting**, **filtering**, **paging**, and **grouping** are performed entirely on the client.
34+
35+
To configure local data binding, assign the in-memory collection to the [Json](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.DataManager.html#Syncfusion_Blazor_DataManager_Json) property of the [SfDataManager](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Data.SfDataManager.html) component.
1936

20-
The following sample code demonstrates binding local data through the [SfDataManager](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Data.SfDataManager.html) to the DataGrid component,
2137

2238
```cshtml
2339
@using Syncfusion.Blazor.Data
2440
@using Syncfusion.Blazor.Grids
2541
2642
<SfGrid TValue="EmployeeData" ID="Grid">
27-
<SfDataManager Json=@Employees></SfDataManager>
43+
<SfDataManager Json="@Employees"></SfDataManager>
2844
<GridColumns>
29-
<GridColumn Field=@nameof(EmployeeData.EmployeeID) TextAlign="TextAlign.Center" HeaderText="Employee ID" Width="120"></GridColumn>
30-
<GridColumn Field=@nameof(EmployeeData.Name) HeaderText="First Name" Width="130"></GridColumn>
31-
<GridColumn Field=@nameof(EmployeeData.Title) HeaderText="Title" Width="120"></GridColumn>
45+
<GridColumn Field="@nameof(EmployeeData.EmployeeID)" HeaderText="Employee ID" TextAlign="TextAlign.Center" Width="120"></GridColumn>
46+
<GridColumn Field="@nameof(EmployeeData.Name)" HeaderText="First Name" Width="130"></GridColumn>
47+
<GridColumn Field="@nameof(EmployeeData.Title)" HeaderText="Title" Width="120"></GridColumn>
3248
</GridColumns>
3349
</SfGrid>
3450
35-
@code{
51+
@code {
52+
3653
public class EmployeeData
3754
{
3855
public int EmployeeID { get; set; }
3956
public string Name { get; set; }
4057
public string Title { get; set; }
4158
}
4259
43-
public EmployeeData[] Employees = new EmployeeData[]
60+
private List<EmployeeData> Employees { get; set; } = new()
4461
{
4562
new EmployeeData { EmployeeID = 1, Name = "Nancy Fuller", Title = "Vice President" },
4663
new EmployeeData { EmployeeID = 2, Name = "Steven Buchanan", Title = "Sales Manager" },
@@ -49,21 +66,26 @@ The following sample code demonstrates binding local data through the [SfDataMan
4966
new EmployeeData { EmployeeID = 5, Name = "Steven Peacock", Title = "Inside Sales Coordinator" },
5067
new EmployeeData { EmployeeID = 6, Name = "Janet Buchanan", Title = "Sales Representative" },
5168
new EmployeeData { EmployeeID = 7, Name = "Andrew Fuller", Title = "Inside Sales Coordinator" },
52-
new EmployeeData { EmployeeID = 8, Name = "Steven Davolio", Title = "Inside Sales Coordinato" },
69+
new EmployeeData { EmployeeID = 8, Name = "Steven Davolio", Title = "Inside Sales Coordinator" },
5370
new EmployeeData { EmployeeID = 9, Name = "Janet Davolio", Title = "Sales Representative" },
5471
new EmployeeData { EmployeeID = 10, Name = "Andrew Buchanan", Title = "Sales Representative" }
5572
};
5673
}
5774
```
5875

59-
The following image represents DataGrid bound with local data through the `SfDataManager` component,
6076
![Data Binding in Blazor DataManager Component](./images/blazor-datamanager-binding.png)
6177

6278
## Remote data binding
6379

64-
Remote data can be bound to the Grid component by binding the [SfDataManager](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Data.SfDataManager.html) component to it and then assigning the service end point URL to the [Url](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.DataManager.html#Syncfusion_Blazor_DataManager_Url) property of the [SfDataManager](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Data.SfDataManager.html).
80+
Remote data binding connects a component to data hosted on an external service. This approach is recommended when working with large datasets or when data changes frequently and must be retrieved dynamically.
81+
82+
**Key Benefits**
6583

66-
The following sample code demonstrates binding remote data through the [SfDataManager](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Data.SfDataManager.html) to the DataGrid component,
84+
* Enables integration with external services and APIs.
85+
* Supports large-scale datasets without loading all data into memory.
86+
* Allows server-side execution of operations such as **filtering**, **sorting**, **paging**, and **grouping** for improved performance.
87+
88+
To configure remote data binding in the [DataGrid](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html), set the [Url](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.DataManager.html#Syncfusion_Blazor_DataManager_Url) property to the service endpoint and specify the [Adaptor](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.DataManager.html#Syncfusion_Blazor_DataManager_Adaptor) property in the [SfDataManager](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Data.SfDataManager.htm) component to define how data operations are processed.
6789

6890
```cshtml
6991
@using Syncfusion.Blazor
@@ -73,15 +95,16 @@ The following sample code demonstrates binding remote data through the [SfDataMa
7395
<SfGrid TValue="Order" ID="Grid" AllowPaging="true">
7496
<SfDataManager Url="https://js.syncfusion.com/demos/ejServices/Wcf/Northwind.svc/Orders" Adaptor="Adaptors.ODataAdaptor"></SfDataManager>
7597
<GridColumns>
76-
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn>
77-
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
78-
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
79-
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
98+
<GridColumn Field="@nameof(Order.OrderID)" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn>
99+
<GridColumn Field="@nameof(Order.CustomerID)" HeaderText="Customer Name" Width="150"></GridColumn>
100+
<GridColumn Field="@nameof(Order.OrderDate)" HeaderText="Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
101+
<GridColumn Field="@nameof(Order.Freight)" HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
80102
</GridColumns>
81103
</SfGrid>
82104
83-
@code{
84-
public class Order {
105+
@code {
106+
public class Order
107+
{
85108
public int? OrderID { get; set; }
86109
public string CustomerID { get; set; }
87110
public DateTime? OrderDate { get; set; }
@@ -90,5 +113,4 @@ The following sample code demonstrates binding remote data through the [SfDataMa
90113
}
91114
```
92115

93-
The following image represents DataGrid bound with remote data through the `SfDataManager` component,
94116
![Remote Data Binding in Blazor DataManager](./images/blazor-datamanager-remote-binding.png)

0 commit comments

Comments
 (0)